~ubuntu-branches/ubuntu/utopic/travis/utopic

« back to all changes in this revision

Viewing changes to src/moltools.cpp

  • Committer: Package Import Robot
  • Author(s): Daniel Leidert
  • Date: 2014-01-18 20:07:16 UTC
  • mfrom: (1.1.8)
  • Revision ID: package-import@ubuntu.com-20140118200716-whsmcg7fa1eyqecq
Tags: 140117-1
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*****************************************************************************
2
 
    TRAVIS - Trajectory Analyzer and Visualizer
3
 
    http://www.travis-analyzer.de/
4
 
 
5
 
    Copyright (c) 2009-2013 Martin Brehm
6
 
                  2012-2013 Martin Thomas
7
 
 
8
 
    This file written by Martin Brehm.
9
 
 
10
 
    This program is free software: you can redistribute it and/or modify
11
 
    it under the terms of the GNU General Public License as published by
12
 
    the Free Software Foundation, either version 3 of the License, or
13
 
    (at your option) any later version.
14
 
 
15
 
    This program is distributed in the hope that it will be useful,
16
 
    but WITHOUT ANY WARRANTY; without even the implied warranty of
17
 
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
 
    GNU General Public License for more details.
19
 
 
20
 
    You should have received a copy of the GNU General Public License
21
 
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
22
 
*****************************************************************************/
23
 
 
24
 
#include "moltools.h"
25
 
#include "travis.h"
26
 
#include "maintools.h"
27
 
 
28
 
 
29
 
CAtom::CAtom()
30
 
{
31
 
        m_pElement = NULL;
32
 
        m_bExclude = false;
33
 
        m_pMergedTo = NULL;
34
 
        m_iIndex = -1;
35
 
}
36
 
 
37
 
 
38
 
CAtom::~CAtom()
39
 
{
40
 
}
41
 
 
42
 
 
43
 
CVirtualAtom::CVirtualAtom()
44
 
{
45
 
        m_faWeight.SetName("CVirtualAtom::m_faWeight");
46
 
}
47
 
 
48
 
 
49
 
CVirtualAtom::~CVirtualAtom()
50
 
{
51
 
}
52
 
 
53
 
 
54
 
CMolecule::CMolecule()
55
 
{
56
 
        m_iWannierCount = 0;
57
 
        m_sName = NULL;
58
 
        m_fCharge = 0;
59
 
        m_bPseudo = false;
60
 
        m_bChargesAssigned = false;
61
 
 
62
 
        m_baAtomIndex.SetName("CMolecule::m_baAtomIndex");
63
 
        m_waAtomCount.SetName("CMolecule::m_waAtomCount");
64
 
        m_laSingleMolIndex.SetName("CMolecule::m_laSingleMolIndex");
65
 
        m_laVirtualAtoms.SetName("CMolecule::m_laVirtualAtoms");
66
 
        m_oaNewNumbers.SetName("CMolecule::m_oaNewNumbers");
67
 
        m_oaRingAtomTypes.SetName("CMolecule::m_oaRingAtomTypes");
68
 
        m_oaRingAtoms.SetName("CMolecule::m_oaRingAtoms");
69
 
        m_oaCharges.SetName("CMolecule::m_oaCharges");
70
 
}
71
 
 
72
 
 
73
 
CMolecule::~CMolecule()
74
 
{
75
 
        if (m_sName != NULL)
76
 
        {
77
 
                delete[] m_sName;
78
 
                m_sName = NULL;
79
 
        }
80
 
}
81
 
 
82
 
 
83
 
CMolAtom::CMolAtom()
84
 
{
85
 
        m_oaBonds.SetName("CMolAtom::m_oaBonds");
86
 
}
87
 
 
88
 
 
89
 
CMolAtom::~CMolAtom()
90
 
{
91
 
}
92
 
 
93
 
 
94
 
CSingleMolecule::CSingleMolecule()
95
 
{
96
 
        m_bPseudo = false;
97
 
 
98
 
        m_oaBondGroups.SetName("CSingleMolecule::m_oaBondGroups");
99
 
        m_oaBonds.SetName("CSingleMolecule::m_oaBonds");
100
 
        m_oaAngleGroups.SetName("CSingleMolecule::m_oaAngleGroups");
101
 
        m_oaAngles.SetName("CSingleMolecule::m_oaAngles");
102
 
        m_oaRings.SetName("CSingleMolecule::m_oaRings");
103
 
        m_laBonds.SetName("CSingleMolecule::m_laBonds");
104
 
        m_laWannier.SetName("CSingleMolecule::m_laWannier");
105
 
        m_oaAtomOffset.SetName("CSingleMolecule::m_oaAtomOffset");
106
 
        m_oaMolAtoms.SetName("CSingleMolecule::m_oaMolAtoms");
107
 
        m_baAtomIndex.SetName("CSingleMolecule::m_baAtomIndex"); 
108
 
}
109
 
 
110
 
 
111
 
CSingleMolecule::~CSingleMolecule()
112
 
{
113
 
}
114
 
 
115
 
 
116
 
CADF::CADF()
117
 
{
118
 
        m_pADF = NULL;
119
 
        m_oaVectors.SetName("CADF::m_oaVectors");
120
 
        m_faACF.SetName("CADF::m_faACF");
121
 
        m_faMinMaxAngle.SetName("CADF::m_faMinMaxAngle");
122
 
}
123
 
 
124
 
 
125
 
CADF::~CADF()
126
 
{
127
 
}
128
 
 
129
 
 
130
 
CDDF::CDDF()
131
 
{
132
 
        m_bRotate = false;
133
 
        m_oaVectors.SetName("CDDF::m_oaVectors");
134
 
        m_faLastData.SetName("CDDF::m_faLastData"); 
135
 
        m_laRotation.SetName("CDDF::m_laRotation");
136
 
        m_faACF.SetName("CDDF::m_faACF");
137
 
}
138
 
 
139
 
 
140
 
CDDF::~CDDF()
141
 
{
142
 
}
143
 
 
144
 
 
145
 
CMSD::CMSD()
146
 
{
147
 
        m_oaCache.SetName("CMSD::m_oaCache");
148
 
}
149
 
 
150
 
 
151
 
CMSD::~CMSD()
152
 
{
153
 
}
154
 
 
155
 
 
156
 
CVHDF::CVHDF()
157
 
{
158
 
        m_sName = NULL;
159
 
        m_sShortName = NULL;
160
 
        m_pVHDF = NULL;
161
 
        m_oaVectors.SetName("CVHDF::m_oaVectors");
162
 
}
163
 
 
164
 
 
165
 
CVHDF::~CVHDF()
166
 
{
167
 
        if (m_sName != NULL)
168
 
        {
169
 
                delete[] m_sName;
170
 
                m_sName = NULL;
171
 
        }
172
 
        if (m_sShortName != NULL)
173
 
        {
174
 
                delete[] m_sShortName;
175
 
                m_sShortName = NULL;
176
 
        }
177
 
        if (m_pVHDF != NULL)
178
 
        {
179
 
                delete m_pVHDF;
180
 
                m_pVHDF = NULL;
181
 
        }
182
 
}
183
 
 
184
 
 
185
 
CRDF::CRDF()
186
 
{
187
 
        m_fDist = NULL;
188
 
        m_pRDF = NULL;
189
 
        m_bProbDens = false;
190
 
        m_faMinMaxDist.SetName("CRDF::m_faMinMaxDist");
191
 
        m_oaVectors.SetName("CRDF::m_oaVectors");
192
 
        m_faACF.SetName("CRDF::m_faACF");
193
 
}
194
 
 
195
 
 
196
 
CPlDF::CPlDF()
197
 
{
198
 
        m_pPlDF = NULL;
199
 
        m_oaVectors.SetName("CPlDF::m_oaVectors");
200
 
        m_faACF.SetName("CPlDF::m_faACF");
201
 
}
202
 
 
203
 
 
204
 
CLiDF::CLiDF()
205
 
{
206
 
        m_pLiDF = NULL;
207
 
        m_oaVectors.SetName("CLiDF::m_oaVectors");
208
 
        m_faACF.SetName("CLiDF::m_faACF");
209
 
}
210
 
 
211
 
 
212
 
CRDF::~CRDF()
213
 
{
214
 
        if (m_sName != NULL)
215
 
        {
216
 
                delete[] m_sName;
217
 
                m_sName = NULL;
218
 
        }
219
 
        if (m_sShortName != NULL)
220
 
        {
221
 
                delete[] m_sShortName;
222
 
                m_sShortName = NULL;
223
 
        }
224
 
        if (m_fDist != NULL)
225
 
        {
226
 
                delete[] m_fDist;
227
 
                m_fDist = NULL;
228
 
        }
229
 
        if (m_pRDF != NULL)
230
 
        {
231
 
                delete m_pRDF;
232
 
                m_pRDF = NULL;
233
 
        }
234
 
        if (m_faData != NULL)
235
 
        {
236
 
                delete[] m_faData;
237
 
                m_faData = NULL;
238
 
        }
239
 
}
240
 
 
241
 
 
242
 
CDensDF::CDensDF()
243
 
{
244
 
        m_pDensDF = NULL;
245
 
}
246
 
 
247
 
 
248
 
CDensDF::~CDensDF()
249
 
{
250
 
        if (m_sName != NULL)
251
 
        {
252
 
                delete[] m_sName;
253
 
                m_sName = NULL;
254
 
        }
255
 
        if (m_sShortName != NULL)
256
 
        {
257
 
                delete[] m_sShortName;
258
 
                m_sShortName = NULL;
259
 
        }
260
 
        if (m_pDensDF != NULL)
261
 
        {
262
 
                delete m_pDensDF;
263
 
                m_pDensDF = NULL;
264
 
        }
265
 
}
266
 
 
267
 
 
268
 
CVDF::CVDF()
269
 
{
270
 
        m_faACF.SetName("CVDF::m_faACF");
271
 
}
272
 
 
273
 
 
274
 
CVDF::~CVDF()
275
 
{
276
 
}
277
 
 
278
 
 
279
 
CDipDF::CDipDF()
280
 
{
281
 
        m_faACF.SetName("CDipDF::m_faACF");
282
 
}
283
 
 
284
 
 
285
 
CDipDF::~CDipDF()
286
 
{
287
 
}
288
 
 
289
 
 
290
 
CSDF::CSDF()
291
 
{
292
 
        m_pCutPlane = NULL;
293
 
        m_fPosCounter = 0;
294
 
        m_fAtom2PosX = 0;
295
 
        m_fAtom3PosX = 0;
296
 
        m_fAtom3PosY = 0;
297
 
}
298
 
 
299
 
 
300
 
CSDF::~CSDF()
301
 
{
302
 
}
303
 
 
304
 
 
305
 
CCDF::CCDF()
306
 
{
307
 
        m_bAxisDivide = false;
308
 
}
309
 
 
310
 
 
311
 
CCDF::~CCDF()
312
 
{
313
 
}
314
 
 
315
 
 
316
 
CConditionSubGroup::CConditionSubGroup()
317
 
{
318
 
        m_fPassed = 0;
319
 
        m_fTotal = 0;
320
 
        m_oaConditions.SetName("CConditionSubGroup::m_oaConditions");
321
 
}
322
 
 
323
 
 
324
 
CConditionSubGroup::~CConditionSubGroup()
325
 
{
326
 
}
327
 
 
328
 
 
329
 
CConditionGroup::CConditionGroup()
330
 
{
331
 
        m_pTable = NULL;
332
 
        m_bInactive = false;
333
 
        m_fPassed = 0;
334
 
        m_fTotal = 0;
335
 
        m_iPassCounter = NULL;
336
 
        m_bAlwaysTrue = NULL;
337
 
        m_oaConditionSubGroups.SetName("CConditionGroup::m_oaConditionSubGroups");
338
 
}
339
 
 
340
 
 
341
 
CConditionGroup::~CConditionGroup()
342
 
{
343
 
}
344
 
 
345
 
 
346
 
bool ContainsDigit(const char *s)
347
 
{
348
 
        if (strcspn(s,"0123456789") != strlen(s))
349
 
                return true;
350
 
        return false;
351
 
}
352
 
 
353
 
 
354
 
void ReplaceDigits(char *s)
355
 
{
356
 
        char buf[32];
357
 
        char *p, *q;
358
 
        bool b;
359
 
 
360
 
        p = s;
361
 
        q = buf;
362
 
        b = false;
363
 
        while (*p != 0)
364
 
        {
365
 
                if (b)
366
 
                {
367
 
                        switch(*p)
368
 
                        {
369
 
                                case '1': *q = 'a'; break;
370
 
                                case '2': *q = 'b'; break;
371
 
                                case '3': *q = 'c'; break;
372
 
                                case '4': *q = 'd'; break;
373
 
                                case '5': *q = 'e'; break;
374
 
                                case '6': *q = 'f'; break;
375
 
                                case '7': *q = 'g'; break;
376
 
                                case '8': *q = 'h'; break;
377
 
                                case '9': *q = 'i'; break;
378
 
                                case '0': *q = 'z'; break;
379
 
                                default: *q = *p;
380
 
                        }
381
 
                } else
382
 
                {
383
 
                        switch(*p)
384
 
                        {
385
 
                                case '1': b = true; *q = '_'; q++; *q = 'a'; break;
386
 
                                case '2': b = true; *q = '_'; q++; *q = 'b'; break;
387
 
                                case '3': b = true; *q = '_'; q++; *q = 'c'; break;
388
 
                                case '4': b = true; *q = '_'; q++; *q = 'd'; break;
389
 
                                case '5': b = true; *q = '_'; q++; *q = 'e'; break;
390
 
                                case '6': b = true; *q = '_'; q++; *q = 'f'; break;
391
 
                                case '7': b = true; *q = '_'; q++; *q = 'g'; break;
392
 
                                case '8': b = true; *q = '_'; q++; *q = 'h'; break;
393
 
                                case '9': b = true; *q = '_'; q++; *q = 'i'; break;
394
 
                                case '0': b = true; *q = '_'; q++; *q = 'z'; break;
395
 
                                default: *q = *p;
396
 
                        }
397
 
                }
398
 
                p++;
399
 
                q++;
400
 
        }
401
 
        *q = 0;
402
 
        strcpy(s,buf);
403
 
}
404
 
 
405
 
 
406
 
void xAddAtom(const char *s)
407
 
{
408
 
        BTIN;
409
 
        int z;
410
 
        CAtom *a;
411
 
        char buf[64];
412
 
 
413
 
        if (g_oaAtoms.GetSize() >= 254)
414
 
        {
415
 
                eprintf("More than 254 different atom types not supported.\n");
416
 
                return;
417
 
        }
418
 
 
419
 
        strcpy(buf,s);
420
 
        ReplaceDigits(buf);
421
 
 
422
 
//      printf("AddAtom: \"%s\".\n",s);
423
 
        for (z=0;z<g_oaAtoms.GetSize();z++)
424
 
        {
425
 
                if (mystricmp(buf,((CAtom*)g_oaAtoms[z])->m_sName)==0)
426
 
                {
427
 
                        ((CAtom*)g_oaAtoms[z])->m_iCount++;
428
 
                        BTOUT; 
429
 
                        return;
430
 
                }
431
 
        }
432
 
        if (ContainsDigit(s))
433
 
                eprintf("Digits in element labels not allowed. Renaming %s to %s.\n",s,buf);
434
 
 
435
 
        try { a = new CAtom(); } catch(...) { a = NULL; }
436
 
        if (a == NULL) NewException((double)sizeof(CAtom),__FILE__,__LINE__,__PRETTY_FUNCTION__);
437
 
        
438
 
        a->m_iIndex = g_oaAtoms.GetSize();
439
 
        strcpy(a->m_sName,buf);
440
 
        if (islower(a->m_sName[0]))
441
 
                a->m_sName[0] = toupper(a->m_sName[0]);
442
 
        if (strlen(a->m_sName) > 1)
443
 
                if (isupper(a->m_sName[1]))
444
 
                        a->m_sName[1] = tolower(a->m_sName[1]);
445
 
        a->m_iCount = 1;
446
 
/*      if (s[0] != '#')
447
 
        {*/
448
 
                a->m_pElement = FindElement(buf,false);
449
 
                if (a->m_pElement == NULL)
450
 
                {
451
 
                        try { a->m_pElement = new CElement(); } catch(...) { a->m_pElement = NULL; }
452
 
                        if (a->m_pElement == NULL) NewException((double)sizeof(CElement),__FILE__,__LINE__,__PRETTY_FUNCTION__);
453
 
                        
454
 
                        try { a->m_pElement->m_sLabel = new char[strlen(a->m_sName)+1]; } catch(...) { a->m_pElement->m_sLabel = NULL; }
455
 
                        if (a->m_pElement->m_sLabel == NULL) NewException((double)(strlen(a->m_sName)+1)*sizeof(char),__FILE__,__LINE__,__PRETTY_FUNCTION__);
456
 
                        
457
 
                        strcpy(a->m_pElement->m_sLabel,a->m_sName);
458
 
                }
459
 
/*              a->m_fMass = AtomMass(s);
460
 
                a->m_fRadius = AtomRadius(s);
461
 
                a->m_iOrd = AtomOrd(s);*/
462
 
//              a->m_fVDWRadius = AtomVDWRadius(s);
463
 
/*      } else
464
 
        {
465
 
                a->m_fMass = 0.0f;
466
 
                a->m_fRadius = 0.0f;
467
 
                a->m_iOrd = 0;
468
 
//              a->m_fVDWRadius = 0.0f;
469
 
        }*/
470
 
        g_oaAtoms.Add(a);
471
 
//      g_pAtoms[g_iElementCount].Offset = offset;
472
 
//      printf("Fuege Atom %s an Stelle %d neu hinzu. Der Offset ist %d.\n",s,g_iAtomCount,offset);
473
 
//      g_iElementCount++;
474
 
        BTOUT; 
475
 
}
476
 
 
477
 
 
478
 
void CSingleMolecule::Dump()
479
 
{
480
 
        BTIN;
481
 
        int z, z2;
482
 
        mprintf("### Single Molecule Dump ###\n");
483
 
        mprintf("%d Elemente.\n",m_baAtomIndex.GetSize());
484
 
        for (z=0;z<m_baAtomIndex.GetSize();z++)
485
 
        {
486
 
                mprintf(" * Element %d: %s. %d Vertreter *\n    Atome ",z+1,((CAtom*)g_oaAtoms[m_baAtomIndex[z]])->m_sName,((CxIntArray*)m_oaAtomOffset[z])->GetSize());
487
 
                for (z2=0;z2<((CxIntArray*)m_oaAtomOffset[z])->GetSize();z2++)
488
 
                {
489
 
                        mprintf("%d",((CxIntArray*)m_oaAtomOffset[z])->GetAt(z2));
490
 
                        if (z2 < ((CxIntArray*)m_oaAtomOffset[z])->GetSize()-1)
491
 
                                mprintf(", ");
492
 
                }
493
 
                mprintf("\n");
494
 
        }
495
 
        BTOUT;
496
 
}
497
 
 
498
 
 
499
 
void CMolecule::Dump()
500
 
{
501
 
        BTIN;
502
 
        int z;
503
 
        mprintf("### Molecule Type Dump ###\n");
504
 
        mprintf("%d Elemente.\n",m_baAtomIndex.GetSize());
505
 
        for (z=0;z<m_baAtomIndex.GetSize();z++)
506
 
                mprintf(" * Element %d: %s. %d Vertreter *\n",z+1,((CAtom*)g_oaAtoms[m_baAtomIndex[z]])->m_sName,m_waAtomCount[z]);
507
 
        BTOUT;
508
 
}
509
 
 
510
 
 
511
 
void CADF::BuildName()
512
 
{
513
 
        BTIN;
514
 
        int z, z2;
515
 
        char tmp[256];
516
 
        CAtomGroup *ag;
517
 
 
518
 
        tmp[0] = 0;
519
 
        if (m_iDeriv != 0)
520
 
                sprintf(tmp,"deriv%d_",m_iDeriv);
521
 
        for (z2=0;z2<m_oaVectors.GetSize()/6;z2++)
522
 
        {
523
 
                for (z=0;z<2;z++)
524
 
                {
525
 
                        strcat(tmp,"[");
526
 
                        if (m_iVecType[z] == 0) // Position
527
 
                        {
528
 
                                if (m_bOrtho[z])
529
 
                                {
530
 
/*                                      if (m_bSameFoot && (z == 1))
531
 
                                                ag = (CAtomGroup*)m_oaVectors[z2*6];
532
 
                                                        else */ag = (CAtomGroup*)m_oaVectors[z2*6+z*3];
533
 
                                        strcat(tmp,ag->m_sName);
534
 
                                        if (m_iRefOrSec[z][0])
535
 
                                                strcat(tmp,"o_");
536
 
                                                        else strcat(tmp,"r_");
537
 
                                        strcat(tmp,((CAtomGroup*)m_oaVectors[z2*6+z*3+1])->m_sName);
538
 
                                        if (m_iRefOrSec[z][1])
539
 
                                                strcat(tmp,"o_");
540
 
                                                        else strcat(tmp,"r_");
541
 
                                        strcat(tmp,((CAtomGroup*)m_oaVectors[z2*6+z*3+2])->m_sName);
542
 
                                        if (m_iRefOrSec[z][2])
543
 
                                                strcat(tmp,"o");
544
 
                                                        else strcat(tmp,"r");
545
 
                                } else
546
 
                                {
547
 
                        /*              if (m_bSameFoot && (z == 1))
548
 
                                                ag = (CAtomGroup*)m_oaVectors[z2*6];
549
 
                                                        else */ag = (CAtomGroup*)m_oaVectors[z2*6+z*3];
550
 
                                        strcat(tmp,ag->m_sName);
551
 
                                        if (m_iRefOrSec[z][0])
552
 
                                                strcat(tmp,"o_");
553
 
                                                        else strcat(tmp,"r_");
554
 
                                        strcat(tmp,((CAtomGroup*)m_oaVectors[z2*6+z*3+1])->m_sName);
555
 
                                        if (m_iRefOrSec[z][1])
556
 
                                                strcat(tmp,"o");
557
 
                                                        else strcat(tmp,"r");
558
 
                                }
559
 
                        } else if (m_iVecType[z] == 1) // Dipol
560
 
                        {
561
 
                                strcat(tmp,"dip_");
562
 
                                strcat(tmp,(m_iRefOrSec[z][0]!=0)?((CMolecule*)g_oaMolecules[m_iShowMol])->m_sName:((CMolecule*)g_oaMolecules[g_iFixMol])->m_sName);
563
 
                        } else if (m_iVecType[z] == 2) // Geschwindigkeit
564
 
                        {
565
 
                                strcat(tmp,"vel_");
566
 
                                strcat(tmp,((CAtomGroup*)m_oaVectors[z*3])->m_sName);
567
 
                        } else if (m_iVecType[z] == 3) // Kraft
568
 
                        {
569
 
                                strcat(tmp,"frc_");
570
 
                                strcat(tmp,((CAtomGroup*)m_oaVectors[z*3])->m_sName);
571
 
                        }
572
 
                        if (z == 0)
573
 
                                strcat(tmp,"]-");
574
 
                                        else strcat(tmp,"]");
575
 
                }
576
 
                if (z2<(m_oaVectors.GetSize()/6)-1)
577
 
                        strcat(tmp,"_");
578
 
        }
579
 
 
580
 
        try { m_sShortName = new char[strlen(tmp)+1]; } catch(...) { m_sShortName = NULL; }
581
 
        if (m_sShortName == NULL) NewException((double)(strlen(tmp)+1)*sizeof(char),__FILE__,__LINE__,__PRETTY_FUNCTION__);
582
 
        
583
 
        strcpy(m_sShortName,tmp);
584
 
        if (m_iShowMol != -1)
585
 
                sprintf(tmp,"%s_%s%d_%s_",((CMolecule*)g_oaMolecules[g_iFixMol])->m_sName,((CAtom*)g_oaAtoms[g_iFixRealAtomType[0]])->m_sName,g_iFixAtom[0]+1,((CMolecule*)g_oaMolecules[m_iShowMol])->m_sName);
586
 
                        else sprintf(tmp,"%s_%s%d_",((CMolecule*)g_oaMolecules[g_iFixMol])->m_sName,((CAtom*)g_oaAtoms[g_iFixRealAtomType[0]])->m_sName,g_iFixAtom[0]+1);
587
 
        strcat(tmp,m_sShortName);
588
 
 
589
 
        try { m_sName = new char[strlen(tmp)+1]; } catch(...) { m_sName = NULL; }
590
 
        if (m_sName == NULL) NewException((double)(strlen(tmp)+1)*sizeof(char),__FILE__,__LINE__,__PRETTY_FUNCTION__);
591
 
        
592
 
        strcpy(m_sName,tmp);
593
 
        BTOUT;
594
 
}
595
 
 
596
 
 
597
 
void CPlDF::BuildName()
598
 
{
599
 
        BTIN;
600
 
        char tmp[256];
601
 
        CAtomGroup *ag;
602
 
 
603
 
        tmp[0] = 0;
604
 
 
605
 
        strcat(tmp,"[");
606
 
        if (m_bNormal)
607
 
        {
608
 
                ag = (CAtomGroup*)m_oaVectors[0];
609
 
                strcat(tmp,ag->m_sName);
610
 
                if (m_iRefOrSec[0])
611
 
                        strcat(tmp,"o_");
612
 
                                else strcat(tmp,"r_");
613
 
                strcat(tmp,((CAtomGroup*)m_oaVectors[1])->m_sName);
614
 
                if (m_iRefOrSec[1])
615
 
                        strcat(tmp,"o");
616
 
                                else strcat(tmp,"r");
617
 
        } else
618
 
        {
619
 
                ag = (CAtomGroup*)m_oaVectors[0];
620
 
                strcat(tmp,ag->m_sName);
621
 
                if (m_iRefOrSec[0])
622
 
                        strcat(tmp,"o_");
623
 
                                else strcat(tmp,"r_");
624
 
                strcat(tmp,((CAtomGroup*)m_oaVectors[1])->m_sName);
625
 
                if (m_iRefOrSec[1])
626
 
                        strcat(tmp,"o_");
627
 
                                else strcat(tmp,"r_");
628
 
                strcat(tmp,((CAtomGroup*)m_oaVectors[2])->m_sName);
629
 
                if (m_iRefOrSec[2])
630
 
                        strcat(tmp,"o");
631
 
                                else strcat(tmp,"r");
632
 
        }
633
 
        strcat(tmp,"]_");
634
 
        strcat(tmp,((CAtomGroup*)m_oaVectors[3])->m_sName);
635
 
        if (m_iRefOrSec[3])
636
 
                strcat(tmp,"o");
637
 
                        else strcat(tmp,"r");
638
 
 
639
 
        try { m_sShortName = new char[strlen(tmp)+1]; } catch(...) { m_sShortName = NULL; }
640
 
        if (m_sShortName == NULL) NewException((double)(strlen(tmp)+1)*sizeof(char),__FILE__,__LINE__,__PRETTY_FUNCTION__);
641
 
        
642
 
        strcpy(m_sShortName,tmp);
643
 
        if (m_iShowMol != -1)
644
 
                sprintf(tmp,"%s_%s%d_%s_",((CMolecule*)g_oaMolecules[g_iFixMol])->m_sName,((CAtom*)g_oaAtoms[g_iFixRealAtomType[0]])->m_sName,g_iFixAtom[0]+1,((CMolecule*)g_oaMolecules[m_iShowMol])->m_sName);
645
 
                        else sprintf(tmp,"%s_%s%d_",((CMolecule*)g_oaMolecules[g_iFixMol])->m_sName,((CAtom*)g_oaAtoms[g_iFixRealAtomType[0]])->m_sName,g_iFixAtom[0]+1);
646
 
        strcat(tmp,m_sShortName);
647
 
 
648
 
        try { m_sName = new char[strlen(tmp)+1]; } catch(...) { m_sName = NULL; }
649
 
        if (m_sName == NULL) NewException((double)(strlen(tmp)+1)*sizeof(char),__FILE__,__LINE__,__PRETTY_FUNCTION__);
650
 
        
651
 
        strcpy(m_sName,tmp);
652
 
        BTOUT;
653
 
}
654
 
 
655
 
 
656
 
void CLiDF::BuildName()
657
 
{
658
 
        BTIN;
659
 
        char tmp[256];
660
 
        CAtomGroup *ag;
661
 
 
662
 
        tmp[0] = 0;
663
 
 
664
 
        strcat(tmp,"[");
665
 
        if (m_bNormal)
666
 
        {
667
 
                ag = (CAtomGroup*)m_oaVectors[0];
668
 
                strcat(tmp,ag->m_sName);
669
 
                if (m_iRefOrSec[0])
670
 
                        strcat(tmp,"o_");
671
 
                                else strcat(tmp,"r_");
672
 
                strcat(tmp,((CAtomGroup*)m_oaVectors[1])->m_sName);
673
 
                if (m_iRefOrSec[1])
674
 
                        strcat(tmp,"o_");
675
 
                                else strcat(tmp,"r_");
676
 
                strcat(tmp,((CAtomGroup*)m_oaVectors[2])->m_sName);
677
 
                if (m_iRefOrSec[2])
678
 
                        strcat(tmp,"o");
679
 
                                else strcat(tmp,"r");
680
 
        } else
681
 
        {
682
 
                ag = (CAtomGroup*)m_oaVectors[0];
683
 
                strcat(tmp,ag->m_sName);
684
 
                if (m_iRefOrSec[0])
685
 
                        strcat(tmp,"o_");
686
 
                                else strcat(tmp,"r_");
687
 
                strcat(tmp,((CAtomGroup*)m_oaVectors[1])->m_sName);
688
 
                if (m_iRefOrSec[1])
689
 
                        strcat(tmp,"o");
690
 
                                else strcat(tmp,"r");
691
 
        }
692
 
        strcat(tmp,"]_");
693
 
        strcat(tmp,((CAtomGroup*)m_oaVectors[3])->m_sName);
694
 
        if (m_iRefOrSec[3])
695
 
                strcat(tmp,"o");
696
 
                        else strcat(tmp,"r");
697
 
 
698
 
        try { m_sShortName = new char[strlen(tmp)+1]; } catch(...) { m_sShortName = NULL; }
699
 
        if (m_sShortName == NULL) NewException((double)(strlen(tmp)+1)*sizeof(char),__FILE__,__LINE__,__PRETTY_FUNCTION__);
700
 
        
701
 
        strcpy(m_sShortName,tmp);
702
 
        if (m_iShowMol != -1)
703
 
                sprintf(tmp,"%s_%s%d_%s_",((CMolecule*)g_oaMolecules[g_iFixMol])->m_sName,((CAtom*)g_oaAtoms[g_iFixRealAtomType[0]])->m_sName,g_iFixAtom[0]+1,((CMolecule*)g_oaMolecules[m_iShowMol])->m_sName);
704
 
                        else sprintf(tmp,"%s_%s%d_",((CMolecule*)g_oaMolecules[g_iFixMol])->m_sName,((CAtom*)g_oaAtoms[g_iFixRealAtomType[0]])->m_sName,g_iFixAtom[0]+1);
705
 
        strcat(tmp,m_sShortName);
706
 
 
707
 
        try { m_sName = new char[strlen(tmp)+1]; } catch(...) { m_sName = NULL; }
708
 
        if (m_sName == NULL) NewException((double)(strlen(tmp)+1)*sizeof(char),__FILE__,__LINE__,__PRETTY_FUNCTION__);
709
 
        
710
 
        strcpy(m_sName,tmp);
711
 
        BTOUT;
712
 
}
713
 
 
714
 
 
715
 
void CDDF::BuildName()
716
 
{
717
 
        BTIN;
718
 
        int z;
719
 
        char tmp[256];
720
 
        CAtomGroup *ag;
721
 
 
722
 
        tmp[0] = 0;
723
 
        if (m_iDeriv != 0)
724
 
                sprintf(tmp,"deriv%d_",m_iDeriv);
725
 
        for (z=0;z<3;z++)
726
 
        {
727
 
                strcat(tmp,"[");
728
 
                if (m_bOrtho[z])
729
 
                {
730
 
                        ag = (CAtomGroup*)m_oaVectors[z*3];
731
 
                        strcat(tmp,ag->m_sName);
732
 
                        if (m_iRefOrSec[z][0])
733
 
                                strcat(tmp,"o_");
734
 
                                        else strcat(tmp,"r_");
735
 
                        strcat(tmp,((CAtomGroup*)m_oaVectors[z*3+1])->m_sName);
736
 
                        if (m_iRefOrSec[z][1])
737
 
                                strcat(tmp,"o_");
738
 
                                        else strcat(tmp,"r_");
739
 
                        strcat(tmp,((CAtomGroup*)m_oaVectors[z*3+2])->m_sName);
740
 
                        if (m_iRefOrSec[z][2])
741
 
                                strcat(tmp,"o");
742
 
                                        else strcat(tmp,"r");
743
 
                } else
744
 
                {
745
 
                        ag = (CAtomGroup*)m_oaVectors[z*3];
746
 
                        strcat(tmp,ag->m_sName);
747
 
                        if (m_iRefOrSec[z][0])
748
 
                                strcat(tmp,"o_");
749
 
                                        else strcat(tmp,"r_");
750
 
                        strcat(tmp,((CAtomGroup*)m_oaVectors[z*3+1])->m_sName);
751
 
                        if (m_iRefOrSec[z][1])
752
 
                                strcat(tmp,"o");
753
 
                                        else strcat(tmp,"r");
754
 
                }
755
 
                if (z < 2)
756
 
                        strcat(tmp,"]-");
757
 
                                else strcat(tmp,"]");
758
 
        }
759
 
 
760
 
        try { m_sShortName = new char[strlen(tmp)+1]; } catch(...) { m_sShortName = NULL; }
761
 
        if (m_sShortName == NULL) NewException((double)(strlen(tmp)+1)*sizeof(char),__FILE__,__LINE__,__PRETTY_FUNCTION__);
762
 
        
763
 
        strcpy(m_sShortName,tmp);
764
 
        if (m_iShowMol != -1)
765
 
                sprintf(tmp,"%s_%s%d_%s_",((CMolecule*)g_oaMolecules[g_iFixMol])->m_sName,((CAtom*)g_oaAtoms[g_iFixRealAtomType[0]])->m_sName,g_iFixAtom[0]+1,((CMolecule*)g_oaMolecules[m_iShowMol])->m_sName);
766
 
                        else sprintf(tmp,"%s_%s%d_",((CMolecule*)g_oaMolecules[g_iFixMol])->m_sName,((CAtom*)g_oaAtoms[g_iFixRealAtomType[0]])->m_sName,g_iFixAtom[0]+1);
767
 
        strcat(tmp,m_sShortName);
768
 
 
769
 
        try { m_sName = new char[strlen(tmp)+1]; } catch(...) { m_sName = NULL; }
770
 
        if (m_sName == NULL) NewException((double)(strlen(tmp)+1)*sizeof(char),__FILE__,__LINE__,__PRETTY_FUNCTION__);
771
 
        
772
 
        strcpy(m_sName,tmp);
773
 
        BTOUT;
774
 
}
775
 
 
776
 
 
777
 
void CDipDF::BuildName()
778
 
{
779
 
        BTIN;
780
 
        char tmp[256];
781
 
 
782
 
        tmp[0] = 0;
783
 
        if (m_iDeriv != 0)
784
 
                sprintf(tmp,"deriv%d_",m_iDeriv);
785
 
        if (m_iRefOrSec)
786
 
                sprintf(tmp,"%s",((CMolecule*)g_oaMolecules[m_iShowMol])->m_sName);
787
 
                        else sprintf(tmp,"%s",((CMolecule*)g_oaMolecules[g_iFixMol])->m_sName);
788
 
 
789
 
        try { m_sName = new char[strlen(tmp)+1]; } catch(...) { m_sName = NULL; }
790
 
        if (m_sName == NULL) NewException((double)(strlen(tmp)+1)*sizeof(char),__FILE__,__LINE__,__PRETTY_FUNCTION__);
791
 
 
792
 
        strcpy(m_sName,tmp);
793
 
 
794
 
        try { m_sShortName = new char[strlen(tmp)+1]; } catch(...) { m_sShortName = NULL; }
795
 
        if (m_sShortName == NULL) NewException((double)(strlen(tmp)+1)*sizeof(char),__FILE__,__LINE__,__PRETTY_FUNCTION__);
796
 
        
797
 
        strcpy(m_sShortName,tmp);
798
 
        BTOUT;
799
 
}
800
 
 
801
 
 
802
 
void CADF::BuildAtomList(CSingleMolecule *ref, CSingleMolecule *obs, CxIntArray *vec)
803
 
{
804
 
        BXIN;
805
 
        int z, z1t, z1a, z2t, z2a, z3t, z3a, z4t, z4a, z5t, z5a, z6t, z6a;
806
 
        CAtomGroup *g1, *g2, *g3, *g4, *g5, *g6;
807
 
        CxIntArray *a1, *a2, *a3, *a4, *a5, *a6;
808
 
 
809
 
        vec->RemoveAll_KeepSize();
810
 
        for (z=0;z<m_oaVectors.GetSize()/6;z++)
811
 
        {
812
 
                if (m_bOrtho[0])
813
 
                {
814
 
                        g1 = (CAtomGroup*)m_oaVectors[z*6];
815
 
                        g2 = (CAtomGroup*)m_oaVectors[z*6+1];
816
 
                        g3 = (CAtomGroup*)m_oaVectors[z*6+2];
817
 
                        for (z1t=0;z1t<g1->m_baAtomType.GetSize();z1t++)
818
 
                        {
819
 
                                a1 = (CxIntArray*)g1->m_oaAtoms[z1t];
820
 
                                for (z1a=0;z1a<a1->GetSize();z1a++)
821
 
                                {
822
 
                                        for (z2t=0;z2t<g2->m_baAtomType.GetSize();z2t++)
823
 
                                        {
824
 
                                                a2 = (CxIntArray*)g2->m_oaAtoms[z2t];
825
 
                                                for (z2a=0;z2a<a2->GetSize();z2a++)
826
 
                                                {
827
 
                                                        for (z3t=0;z3t<g3->m_baAtomType.GetSize();z3t++)
828
 
                                                        {
829
 
                                                                a3 = (CxIntArray*)g3->m_oaAtoms[z3t];
830
 
                                                                for (z3a=0;z3a<a3->GetSize();z3a++)
831
 
                                                                {
832
 
                                                                        if (m_bOrtho[1])
833
 
                                                                        {
834
 
                                                        /*                      if (m_bSameFoot)
835
 
                                                                                        g4 = g1;
836
 
                                                                                                else */g4 = (CAtomGroup*)m_oaVectors[z*6+3];
837
 
                                                                                g5 = (CAtomGroup*)m_oaVectors[z*6+4];
838
 
                                                                                g6 = (CAtomGroup*)m_oaVectors[z*6+5];
839
 
                                                                                for (z4t=0;z4t<g4->m_baAtomType.GetSize();z4t++)
840
 
                                                                                {
841
 
                                                                /*                      if (m_bSameFoot && (z4t != z1t))
842
 
                                                                                                continue;*/
843
 
                                                                                        a4 = (CxIntArray*)g4->m_oaAtoms[z4t];
844
 
                                                                                        for (z4a=0;z4a<a4->GetSize();z4a++)
845
 
                                                                                        {
846
 
                                                                                /*              if (m_bSameFoot && (z4a != z1a))
847
 
                                                                                                        continue;*/
848
 
                                                                                                for (z5t=0;z5t<g5->m_baAtomType.GetSize();z5t++)
849
 
                                                                                                {
850
 
                                                                                                        a5 = (CxIntArray*)g5->m_oaAtoms[z5t];
851
 
                                                                                                        for (z5a=0;z5a<a5->GetSize();z5a++)
852
 
                                                                                                        {
853
 
                                                                                                                for (z6t=0;z6t<g6->m_baAtomType.GetSize();z6t++)
854
 
                                                                                                                {
855
 
                                                                                                                        a6 = (CxIntArray*)g6->m_oaAtoms[z6t];
856
 
                                                                                                                        for (z6a=0;z6a<a6->GetSize();z6a++)
857
 
                                                                                                                        {
858
 
                                                                                                                                if ((!m_iRefOrSec[0][0]) || (obs == NULL))
859
 
                                                                                                                                        vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g1->m_baAtomType[z1t]])->GetAt(a1->GetAt(z1a)));
860
 
                                                                                                                                                else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g1->m_baAtomType[z1t]])->GetAt(a1->GetAt(z1a)));
861
 
                                                                                                                                if ((!m_iRefOrSec[0][1]) || (obs == NULL))
862
 
                                                                                                                                        vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g2->m_baAtomType[z2t]])->GetAt(a2->GetAt(z2a)));
863
 
                                                                                                                                                else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g2->m_baAtomType[z2t]])->GetAt(a2->GetAt(z2a)));
864
 
                                                                                                                                if ((!m_iRefOrSec[0][2]) || (obs == NULL))
865
 
                                                                                                                                        vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g3->m_baAtomType[z3t]])->GetAt(a3->GetAt(z3a)));
866
 
                                                                                                                                                else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g3->m_baAtomType[z3t]])->GetAt(a3->GetAt(z3a)));
867
 
                                                                                                                                if ((!m_iRefOrSec[1][0]) || (obs == NULL))
868
 
                                                                                                                                        vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g4->m_baAtomType[z4t]])->GetAt(a4->GetAt(z4a)));
869
 
                                                                                                                                                else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g4->m_baAtomType[z4t]])->GetAt(a4->GetAt(z4a)));
870
 
                                                                                                                                if ((!m_iRefOrSec[1][1]) || (obs == NULL))
871
 
                                                                                                                                        vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g5->m_baAtomType[z5t]])->GetAt(a5->GetAt(z5a)));
872
 
                                                                                                                                                else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g5->m_baAtomType[z5t]])->GetAt(a5->GetAt(z5a)));
873
 
                                                                                                                                if ((!m_iRefOrSec[1][2]) || (obs == NULL))
874
 
                                                                                                                                        vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g6->m_baAtomType[z6t]])->GetAt(a6->GetAt(z6a)));
875
 
                                                                                                                                                else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g6->m_baAtomType[z6t]])->GetAt(a6->GetAt(z6a)));
876
 
                                                                                                                        }
877
 
                                                                                                                }
878
 
                                                                                                        }
879
 
                                                                                                }
880
 
                                                                                        }
881
 
                                                                                }
882
 
                                                                        } else
883
 
                                                                        {
884
 
                                                                /*              if (m_bSameFoot)
885
 
                                                                                        g4 = g1;
886
 
                                                                                                else */g4 = (CAtomGroup*)m_oaVectors[z*6+3];
887
 
                                                                                g5 = (CAtomGroup*)m_oaVectors[z*6+4];
888
 
                                                                                for (z4t=0;z4t<g4->m_baAtomType.GetSize();z4t++)
889
 
                                                                                {
890
 
                                                                /*                      if (m_bSameFoot && (z4t != z1t))
891
 
                                                                                                continue;*/
892
 
                                                                                        a4 = (CxIntArray*)g4->m_oaAtoms[z4t];
893
 
                                                                                        for (z4a=0;z4a<a4->GetSize();z4a++)
894
 
                                                                                        {
895
 
                                                                        /*                      if (m_bSameFoot && (z4a != z1a))
896
 
                                                                                                        continue;*/
897
 
                                                                                                for (z5t=0;z5t<g5->m_baAtomType.GetSize();z5t++)
898
 
                                                                                                {
899
 
                                                                                                        a5 = (CxIntArray*)g5->m_oaAtoms[z5t];
900
 
                                                                                                        for (z5a=0;z5a<a5->GetSize();z5a++)
901
 
                                                                                                        {
902
 
                                                                                                                if ((!m_iRefOrSec[0][0]) || (obs == NULL))
903
 
                                                                                                                        vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g1->m_baAtomType[z1t]])->GetAt(a1->GetAt(z1a)));
904
 
                                                                                                                                else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g1->m_baAtomType[z1t]])->GetAt(a1->GetAt(z1a)));
905
 
                                                                                                                if ((!m_iRefOrSec[0][1]) || (obs == NULL))
906
 
                                                                                                                        vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g2->m_baAtomType[z2t]])->GetAt(a2->GetAt(z2a)));
907
 
                                                                                                                                else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g2->m_baAtomType[z2t]])->GetAt(a2->GetAt(z2a)));
908
 
                                                                                                                if ((!m_iRefOrSec[0][2]) || (obs == NULL))
909
 
                                                                                                                        vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g3->m_baAtomType[z3t]])->GetAt(a3->GetAt(z3a)));
910
 
                                                                                                                                else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g3->m_baAtomType[z3t]])->GetAt(a3->GetAt(z3a)));
911
 
                                                                                                                if ((!m_iRefOrSec[1][0]) || (obs == NULL))
912
 
                                                                                                                        vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g4->m_baAtomType[z4t]])->GetAt(a4->GetAt(z4a)));
913
 
                                                                                                                                else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g4->m_baAtomType[z4t]])->GetAt(a4->GetAt(z4a)));
914
 
                                                                                                                if ((!m_iRefOrSec[1][1]) || (obs == NULL))
915
 
                                                                                                                        vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g5->m_baAtomType[z5t]])->GetAt(a5->GetAt(z5a)));
916
 
                                                                                                                                else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g5->m_baAtomType[z5t]])->GetAt(a5->GetAt(z5a)));
917
 
                                                                                                                vec->Add(0);
918
 
                                                                                                        }
919
 
                                                                                                }
920
 
                                                                                        }
921
 
                                                                                }
922
 
                                                                        } // END IF NOT ORTHO[1]
923
 
                                                                }
924
 
                                                        }
925
 
                                                }
926
 
                                        }
927
 
                                }
928
 
                        }
929
 
                } else
930
 
                {
931
 
                        g1 = (CAtomGroup*)m_oaVectors[z*6];
932
 
                        g2 = (CAtomGroup*)m_oaVectors[z*6+1];
933
 
                        for (z1t=0;z1t<g1->m_baAtomType.GetSize();z1t++)
934
 
                        {
935
 
                                a1 = (CxIntArray*)g1->m_oaAtoms[z1t];
936
 
                                for (z1a=0;z1a<a1->GetSize();z1a++)
937
 
                                {
938
 
                                        for (z2t=0;z2t<g2->m_baAtomType.GetSize();z2t++)
939
 
                                        {
940
 
                                                a2 = (CxIntArray*)g2->m_oaAtoms[z2t];
941
 
                                                for (z2a=0;z2a<a2->GetSize();z2a++)
942
 
                                                {
943
 
                                                        if (m_bOrtho[1])
944
 
                                                        {
945
 
                                                /*              if (m_bSameFoot)
946
 
                                                                        g4 = g1;
947
 
                                                                                else */g4 = (CAtomGroup*)m_oaVectors[z*6+3];
948
 
                                                                g5 = (CAtomGroup*)m_oaVectors[z*6+4];
949
 
                                                                g6 = (CAtomGroup*)m_oaVectors[z*6+5];
950
 
                                                                for (z4t=0;z4t<g4->m_baAtomType.GetSize();z4t++)
951
 
                                                                {
952
 
                                                /*                      if (m_bSameFoot && (z4t != z1t))
953
 
                                                                                continue;*/
954
 
                                                                        a4 = (CxIntArray*)g4->m_oaAtoms[z4t];
955
 
                                                                        for (z4a=0;z4a<a4->GetSize();z4a++)
956
 
                                                                        {
957
 
                                                        /*                      if (m_bSameFoot && (z4a != z1a))
958
 
                                                                                        continue;*/
959
 
                                                                                for (z5t=0;z5t<g5->m_baAtomType.GetSize();z5t++)
960
 
                                                                                {
961
 
                                                                                        a5 = (CxIntArray*)g5->m_oaAtoms[z5t];
962
 
                                                                                        for (z5a=0;z5a<a5->GetSize();z5a++)
963
 
                                                                                        {
964
 
                                                                                                for (z6t=0;z6t<g6->m_baAtomType.GetSize();z6t++)
965
 
                                                                                                {
966
 
                                                                                                        a6 = (CxIntArray*)g6->m_oaAtoms[z6t];
967
 
                                                                                                        for (z6a=0;z6a<a6->GetSize();z6a++)
968
 
                                                                                                        {
969
 
                                                                                                                if ((!m_iRefOrSec[0][0]) || (obs == NULL))
970
 
                                                                                                                        vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g1->m_baAtomType[z1t]])->GetAt(a1->GetAt(z1a)));
971
 
                                                                                                                                else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g1->m_baAtomType[z1t]])->GetAt(a1->GetAt(z1a)));
972
 
                                                                                                                if ((!m_iRefOrSec[0][1]) || (obs == NULL))
973
 
                                                                                                                        vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g2->m_baAtomType[z2t]])->GetAt(a2->GetAt(z2a)));
974
 
                                                                                                                                else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g2->m_baAtomType[z2t]])->GetAt(a2->GetAt(z2a)));
975
 
                                                                                                                vec->Add(0);
976
 
                                                                                                                if ((!m_iRefOrSec[1][0]) || (obs == NULL))
977
 
                                                                                                                        vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g4->m_baAtomType[z4t]])->GetAt(a4->GetAt(z4a)));
978
 
                                                                                                                                else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g4->m_baAtomType[z4t]])->GetAt(a4->GetAt(z4a)));
979
 
                                                                                                                if ((!m_iRefOrSec[1][1]) || (obs == NULL))
980
 
                                                                                                                        vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g5->m_baAtomType[z5t]])->GetAt(a5->GetAt(z5a)));
981
 
                                                                                                                                else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g5->m_baAtomType[z5t]])->GetAt(a5->GetAt(z5a)));
982
 
                                                                                                                if ((!m_iRefOrSec[1][2]) || (obs == NULL))
983
 
                                                                                                                        vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g6->m_baAtomType[z6t]])->GetAt(a6->GetAt(z6a)));
984
 
                                                                                                                                else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g6->m_baAtomType[z6t]])->GetAt(a6->GetAt(z6a)));
985
 
                                                                                                        }
986
 
                                                                                                }
987
 
                                                                                        }
988
 
                                                                                }
989
 
                                                                        }
990
 
                                                                }
991
 
                                                        } else
992
 
                                                        {
993
 
                                                /*              if (m_bSameFoot)
994
 
                                                                        g4 = g1;
995
 
                                                                                else */g4 = (CAtomGroup*)m_oaVectors[z*6+3];
996
 
                                                                g5 = (CAtomGroup*)m_oaVectors[z*6+4];
997
 
                                                                for (z4t=0;z4t<g4->m_baAtomType.GetSize();z4t++)
998
 
                                                                {
999
 
                                                        /*              if (m_bSameFoot && (z4t != z1t))
1000
 
                                                                                continue;*/
1001
 
                                                                        a4 = (CxIntArray*)g4->m_oaAtoms[z4t];
1002
 
                                                                        for (z4a=0;z4a<a4->GetSize();z4a++)
1003
 
                                                                        {
1004
 
                                                                /*              if (m_bSameFoot && (z4a != z1a))
1005
 
                                                                                        continue;*/
1006
 
                                                                                for (z5t=0;z5t<g5->m_baAtomType.GetSize();z5t++)
1007
 
                                                                                {
1008
 
                                                                                        a5 = (CxIntArray*)g5->m_oaAtoms[z5t];
1009
 
                                                                                        for (z5a=0;z5a<a5->GetSize();z5a++)
1010
 
                                                                                        {
1011
 
                                                                                                if ((!m_iRefOrSec[0][0]) || (obs == NULL))
1012
 
                                                                                                        vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g1->m_baAtomType[z1t]])->GetAt(a1->GetAt(z1a)));
1013
 
                                                                                                                else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g1->m_baAtomType[z1t]])->GetAt(a1->GetAt(z1a)));
1014
 
                                                                                                if ((!m_iRefOrSec[0][1]) || (obs == NULL))
1015
 
                                                                                                        vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g2->m_baAtomType[z2t]])->GetAt(a2->GetAt(z2a)));
1016
 
                                                                                                                else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g2->m_baAtomType[z2t]])->GetAt(a2->GetAt(z2a)));
1017
 
                                                                                                vec->Add(0);
1018
 
                                                                                                if ((!m_iRefOrSec[1][0]) || (obs == NULL))
1019
 
                                                                                                        vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g4->m_baAtomType[z4t]])->GetAt(a4->GetAt(z4a)));
1020
 
                                                                                                                else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g4->m_baAtomType[z4t]])->GetAt(a4->GetAt(z4a)));
1021
 
                                                                                                if ((!m_iRefOrSec[1][1]) || (obs == NULL))
1022
 
                                                                                                        vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g5->m_baAtomType[z5t]])->GetAt(a5->GetAt(z5a)));
1023
 
                                                                                                                else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g5->m_baAtomType[z5t]])->GetAt(a5->GetAt(z5a)));
1024
 
                                                                                                vec->Add(0);
1025
 
                                                                                        }
1026
 
                                                                                }
1027
 
                                                                        }
1028
 
                                                                }
1029
 
                                                        } // END IF NOT ORTHO[1]
1030
 
                                                }
1031
 
                                        }
1032
 
                                }
1033
 
                        }
1034
 
                }
1035
 
        }
1036
 
        BXOUT;
1037
 
}
1038
 
 
1039
 
 
1040
 
/* Mega abartig !!!! */
1041
 
void CDDF::BuildAtomList(CSingleMolecule *ref, CSingleMolecule *obs, CxIntArray *vec)
1042
 
{
1043
 
        BXIN;
1044
 
        int z, z1t, z1a, z2t, z2a, z3t, z3a, z4t, z4a, z5t, z5a, z6t, z6a, z7t, z7a, z8t, z8a, z9t, z9a;
1045
 
        CAtomGroup *g1, *g2, *g3, *g4, *g5, *g6, *g7, *g8, *g9;
1046
 
        CxIntArray *a1, *a2, *a3, *a4, *a5, *a6, *a7, *a8, *a9;
1047
 
 
1048
 
        vec->RemoveAll_KeepSize();
1049
 
        for (z=0;z<m_oaVectors.GetSize()/9;z++)
1050
 
        {
1051
 
                if (m_bOrtho[0])
1052
 
                {
1053
 
                        g1 = (CAtomGroup*)m_oaVectors[z*9];
1054
 
                        g2 = (CAtomGroup*)m_oaVectors[z*9+1];
1055
 
                        g3 = (CAtomGroup*)m_oaVectors[z*9+2];
1056
 
                        for (z1t=0;z1t<g1->m_baAtomType.GetSize();z1t++)
1057
 
                        {
1058
 
                                a1 = (CxIntArray*)g1->m_oaAtoms[z1t];
1059
 
                                for (z1a=0;z1a<a1->GetSize();z1a++)
1060
 
                                {
1061
 
                                        for (z2t=0;z2t<g2->m_baAtomType.GetSize();z2t++)
1062
 
                                        {
1063
 
                                                a2 = (CxIntArray*)g2->m_oaAtoms[z2t];
1064
 
                                                for (z2a=0;z2a<a2->GetSize();z2a++)
1065
 
                                                {
1066
 
                                                        for (z3t=0;z3t<g3->m_baAtomType.GetSize();z3t++)
1067
 
                                                        {
1068
 
                                                                a3 = (CxIntArray*)g3->m_oaAtoms[z3t];
1069
 
                                                                for (z3a=0;z3a<a3->GetSize();z3a++)
1070
 
                                                                {
1071
 
                                                                        if (m_bOrtho[1])
1072
 
                                                                        {
1073
 
                                                                                g4 = (CAtomGroup*)m_oaVectors[z*9+3];
1074
 
                                                                                g5 = (CAtomGroup*)m_oaVectors[z*9+4];
1075
 
                                                                                g6 = (CAtomGroup*)m_oaVectors[z*9+5];
1076
 
                                                                                for (z4t=0;z4t<g4->m_baAtomType.GetSize();z4t++)
1077
 
                                                                                {
1078
 
                                                                                        a4 = (CxIntArray*)g4->m_oaAtoms[z4t];
1079
 
                                                                                        for (z4a=0;z4a<a4->GetSize();z4a++)
1080
 
                                                                                        {
1081
 
                                                                                                for (z5t=0;z5t<g5->m_baAtomType.GetSize();z5t++)
1082
 
                                                                                                {
1083
 
                                                                                                        a5 = (CxIntArray*)g5->m_oaAtoms[z5t];
1084
 
                                                                                                        for (z5a=0;z5a<a5->GetSize();z5a++)
1085
 
                                                                                                        {
1086
 
                                                                                                                for (z6t=0;z6t<g6->m_baAtomType.GetSize();z6t++)
1087
 
                                                                                                                {
1088
 
                                                                                                                        a6 = (CxIntArray*)g6->m_oaAtoms[z6t];
1089
 
                                                                                                                        for (z6a=0;z6a<a6->GetSize();z6a++)
1090
 
                                                                                                                        {
1091
 
                                                                                                                                if (m_bOrtho[2])
1092
 
                                                                                                                                {
1093
 
                                                                                                                                        g7 = (CAtomGroup*)m_oaVectors[z*9+6];
1094
 
                                                                                                                                        g8 = (CAtomGroup*)m_oaVectors[z*9+7];
1095
 
                                                                                                                                        g9 = (CAtomGroup*)m_oaVectors[z*9+8];
1096
 
                                                                                                                                        for (z7t=0;z7t<g7->m_baAtomType.GetSize();z7t++)
1097
 
                                                                                                                                        {
1098
 
                                                                                                                                                a7 = (CxIntArray*)g7->m_oaAtoms[z7t];
1099
 
                                                                                                                                                for (z7a=0;z7a<a7->GetSize();z7a++)
1100
 
                                                                                                                                                {
1101
 
                                                                                                                                                        for (z8t=0;z8t<g8->m_baAtomType.GetSize();z8t++)
1102
 
                                                                                                                                                        {
1103
 
                                                                                                                                                                a8 = (CxIntArray*)g8->m_oaAtoms[z8t];
1104
 
                                                                                                                                                                for (z8a=0;z8a<a8->GetSize();z8a++)
1105
 
                                                                                                                                                                {
1106
 
                                                                                                                                                                        for (z9t=0;z9t<g9->m_baAtomType.GetSize();z9t++)
1107
 
                                                                                                                                                                        {
1108
 
                                                                                                                                                                                a9 = (CxIntArray*)g9->m_oaAtoms[z9t];
1109
 
                                                                                                                                                                                for (z9a=0;z9a<a9->GetSize();z9a++)
1110
 
                                                                                                                                                                                {
1111
 
                                                                                                                                                                                        if ((!m_iRefOrSec[0][0]) || (obs == NULL))
1112
 
                                                                                                                                                                                                vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g1->m_baAtomType[z1t]])->GetAt(a1->GetAt(z1a)));
1113
 
                                                                                                                                                                                                        else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g1->m_baAtomType[z1t]])->GetAt(a1->GetAt(z1a)));
1114
 
                                                                                                                                                                                        if ((!m_iRefOrSec[0][1]) || (obs == NULL))
1115
 
                                                                                                                                                                                                vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g2->m_baAtomType[z2t]])->GetAt(a2->GetAt(z2a)));
1116
 
                                                                                                                                                                                                        else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g2->m_baAtomType[z2t]])->GetAt(a2->GetAt(z2a)));
1117
 
                                                                                                                                                                                        if ((!m_iRefOrSec[0][2]) || (obs == NULL))
1118
 
                                                                                                                                                                                                vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g3->m_baAtomType[z3t]])->GetAt(a3->GetAt(z3a)));
1119
 
                                                                                                                                                                                                        else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g3->m_baAtomType[z3t]])->GetAt(a3->GetAt(z3a)));
1120
 
                                                                                                                                                                                        if ((!m_iRefOrSec[1][0]) || (obs == NULL))
1121
 
                                                                                                                                                                                                vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g4->m_baAtomType[z4t]])->GetAt(a4->GetAt(z4a)));
1122
 
                                                                                                                                                                                                        else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g4->m_baAtomType[z4t]])->GetAt(a4->GetAt(z4a)));
1123
 
                                                                                                                                                                                        if ((!m_iRefOrSec[1][1]) || (obs == NULL))
1124
 
                                                                                                                                                                                                vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g5->m_baAtomType[z5t]])->GetAt(a5->GetAt(z5a)));
1125
 
                                                                                                                                                                                                        else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g5->m_baAtomType[z5t]])->GetAt(a5->GetAt(z5a)));
1126
 
                                                                                                                                                                                        if ((!m_iRefOrSec[1][2]) || (obs == NULL))
1127
 
                                                                                                                                                                                                vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g6->m_baAtomType[z6t]])->GetAt(a6->GetAt(z6a)));
1128
 
                                                                                                                                                                                                        else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g6->m_baAtomType[z6t]])->GetAt(a6->GetAt(z6a)));
1129
 
                                                                                                                                                                                        if ((!m_iRefOrSec[2][0]) || (obs == NULL))
1130
 
                                                                                                                                                                                                vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g7->m_baAtomType[z7t]])->GetAt(a7->GetAt(z7a)));
1131
 
                                                                                                                                                                                                        else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g7->m_baAtomType[z7t]])->GetAt(a7->GetAt(z7a)));
1132
 
                                                                                                                                                                                        if ((!m_iRefOrSec[2][1]) || (obs == NULL))
1133
 
                                                                                                                                                                                                vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g8->m_baAtomType[z8t]])->GetAt(a8->GetAt(z8a)));
1134
 
                                                                                                                                                                                                        else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g8->m_baAtomType[z8t]])->GetAt(a8->GetAt(z8a)));
1135
 
                                                                                                                                                                                        if ((!m_iRefOrSec[2][2]) || (obs == NULL))
1136
 
                                                                                                                                                                                                vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g9->m_baAtomType[z9t]])->GetAt(a9->GetAt(z9a)));
1137
 
                                                                                                                                                                                                        else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g9->m_baAtomType[z9t]])->GetAt(a9->GetAt(z9a)));
1138
 
                                                                                                                                                                                }
1139
 
                                                                                                                                                                        }
1140
 
                                                                                                                                                                }
1141
 
                                                                                                                                                        }
1142
 
                                                                                                                                                }
1143
 
                                                                                                                                        }
1144
 
                                                                                                                                } else // IF NOT ORTHO[2]
1145
 
                                                                                                                                {
1146
 
                                                                                                                                        g7 = (CAtomGroup*)m_oaVectors[z*9+6];
1147
 
                                                                                                                                        g8 = (CAtomGroup*)m_oaVectors[z*9+7];
1148
 
                                                                                                                                        for (z7t=0;z7t<g7->m_baAtomType.GetSize();z7t++)
1149
 
                                                                                                                                        {
1150
 
                                                                                                                                                a7 = (CxIntArray*)g7->m_oaAtoms[z7t];
1151
 
                                                                                                                                                for (z7a=0;z7a<a7->GetSize();z7a++)
1152
 
                                                                                                                                                {
1153
 
                                                                                                                                                        for (z8t=0;z8t<g8->m_baAtomType.GetSize();z8t++)
1154
 
                                                                                                                                                        {
1155
 
                                                                                                                                                                a8 = (CxIntArray*)g8->m_oaAtoms[z8t];
1156
 
                                                                                                                                                                for (z8a=0;z8a<a8->GetSize();z8a++)
1157
 
                                                                                                                                                                {
1158
 
                                                                                                                                                                        if ((!m_iRefOrSec[0][0]) || (obs == NULL))
1159
 
                                                                                                                                                                                vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g1->m_baAtomType[z1t]])->GetAt(a1->GetAt(z1a)));
1160
 
                                                                                                                                                                                        else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g1->m_baAtomType[z1t]])->GetAt(a1->GetAt(z1a)));
1161
 
                                                                                                                                                                        if ((!m_iRefOrSec[0][1]) || (obs == NULL))
1162
 
                                                                                                                                                                                vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g2->m_baAtomType[z2t]])->GetAt(a2->GetAt(z2a)));
1163
 
                                                                                                                                                                                        else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g2->m_baAtomType[z2t]])->GetAt(a2->GetAt(z2a)));
1164
 
                                                                                                                                                                        if ((!m_iRefOrSec[0][2]) || (obs == NULL))
1165
 
                                                                                                                                                                                vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g3->m_baAtomType[z3t]])->GetAt(a3->GetAt(z3a)));
1166
 
                                                                                                                                                                                        else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g3->m_baAtomType[z3t]])->GetAt(a3->GetAt(z3a)));
1167
 
                                                                                                                                                                        if ((!m_iRefOrSec[1][0]) || (obs == NULL))
1168
 
                                                                                                                                                                                vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g4->m_baAtomType[z4t]])->GetAt(a4->GetAt(z4a)));
1169
 
                                                                                                                                                                                        else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g4->m_baAtomType[z4t]])->GetAt(a4->GetAt(z4a)));
1170
 
                                                                                                                                                                        if ((!m_iRefOrSec[1][1]) || (obs == NULL))
1171
 
                                                                                                                                                                                vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g5->m_baAtomType[z5t]])->GetAt(a5->GetAt(z5a)));
1172
 
                                                                                                                                                                                        else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g5->m_baAtomType[z5t]])->GetAt(a5->GetAt(z5a)));
1173
 
                                                                                                                                                                        if ((!m_iRefOrSec[1][2]) || (obs == NULL))
1174
 
                                                                                                                                                                                vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g6->m_baAtomType[z6t]])->GetAt(a6->GetAt(z6a)));
1175
 
                                                                                                                                                                                        else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g6->m_baAtomType[z6t]])->GetAt(a6->GetAt(z6a)));
1176
 
                                                                                                                                                                        if ((!m_iRefOrSec[2][0]) || (obs == NULL))
1177
 
                                                                                                                                                                                vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g7->m_baAtomType[z7t]])->GetAt(a7->GetAt(z7a)));
1178
 
                                                                                                                                                                                        else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g7->m_baAtomType[z7t]])->GetAt(a7->GetAt(z7a)));
1179
 
                                                                                                                                                                        if ((!m_iRefOrSec[2][1]) || (obs == NULL))
1180
 
                                                                                                                                                                                vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g8->m_baAtomType[z8t]])->GetAt(a8->GetAt(z8a)));
1181
 
                                                                                                                                                                                        else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g8->m_baAtomType[z8t]])->GetAt(a8->GetAt(z8a)));
1182
 
                                                                                                                                                                        vec->Add(0);
1183
 
                                                                                                                                                                }
1184
 
                                                                                                                                                        }
1185
 
                                                                                                                                                }
1186
 
                                                                                                                                        }
1187
 
                                                                                                                                } // END IF NOT ORTHO[2]
1188
 
                                                                                                                        }
1189
 
                                                                                                                }
1190
 
                                                                                                        }
1191
 
                                                                                                }
1192
 
                                                                                        }
1193
 
                                                                                }
1194
 
                                                                        } else // IF NOT ORTHO[1]
1195
 
                                                                        {
1196
 
                                                                                g4 = (CAtomGroup*)m_oaVectors[z*9+3];
1197
 
                                                                                g5 = (CAtomGroup*)m_oaVectors[z*9+4];
1198
 
                                                                                for (z4t=0;z4t<g4->m_baAtomType.GetSize();z4t++)
1199
 
                                                                                {
1200
 
                                                                                        a4 = (CxIntArray*)g4->m_oaAtoms[z4t];
1201
 
                                                                                        for (z4a=0;z4a<a4->GetSize();z4a++)
1202
 
                                                                                        {
1203
 
                                                                                                for (z5t=0;z5t<g5->m_baAtomType.GetSize();z5t++)
1204
 
                                                                                                {
1205
 
                                                                                                        a5 = (CxIntArray*)g5->m_oaAtoms[z5t];
1206
 
                                                                                                        for (z5a=0;z5a<a5->GetSize();z5a++)
1207
 
                                                                                                        {
1208
 
                                                                                                                if (m_bOrtho[2])
1209
 
                                                                                                                {
1210
 
                                                                                                                        g7 = (CAtomGroup*)m_oaVectors[z*9+6];
1211
 
                                                                                                                        g8 = (CAtomGroup*)m_oaVectors[z*9+7];
1212
 
                                                                                                                        g9 = (CAtomGroup*)m_oaVectors[z*9+8];
1213
 
                                                                                                                        for (z7t=0;z7t<g7->m_baAtomType.GetSize();z7t++)
1214
 
                                                                                                                        {
1215
 
                                                                                                                                a7 = (CxIntArray*)g7->m_oaAtoms[z7t];
1216
 
                                                                                                                                for (z7a=0;z7a<a7->GetSize();z7a++)
1217
 
                                                                                                                                {
1218
 
                                                                                                                                        for (z8t=0;z8t<g8->m_baAtomType.GetSize();z8t++)
1219
 
                                                                                                                                        {
1220
 
                                                                                                                                                a8 = (CxIntArray*)g8->m_oaAtoms[z8t];
1221
 
                                                                                                                                                for (z8a=0;z8a<a8->GetSize();z8a++)
1222
 
                                                                                                                                                {
1223
 
                                                                                                                                                        for (z9t=0;z9t<g9->m_baAtomType.GetSize();z9t++)
1224
 
                                                                                                                                                        {
1225
 
                                                                                                                                                                a9 = (CxIntArray*)g9->m_oaAtoms[z9t];
1226
 
                                                                                                                                                                for (z9a=0;z9a<a9->GetSize();z9a++)
1227
 
                                                                                                                                                                {
1228
 
                                                                                                                                                                        if ((!m_iRefOrSec[0][0]) || (obs == NULL))
1229
 
                                                                                                                                                                                vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g1->m_baAtomType[z1t]])->GetAt(a1->GetAt(z1a)));
1230
 
                                                                                                                                                                                        else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g1->m_baAtomType[z1t]])->GetAt(a1->GetAt(z1a)));
1231
 
                                                                                                                                                                        if ((!m_iRefOrSec[0][1]) || (obs == NULL))
1232
 
                                                                                                                                                                                vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g2->m_baAtomType[z2t]])->GetAt(a2->GetAt(z2a)));
1233
 
                                                                                                                                                                                        else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g2->m_baAtomType[z2t]])->GetAt(a2->GetAt(z2a)));
1234
 
                                                                                                                                                                        if ((!m_iRefOrSec[0][2]) || (obs == NULL))
1235
 
                                                                                                                                                                                vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g3->m_baAtomType[z3t]])->GetAt(a3->GetAt(z3a)));
1236
 
                                                                                                                                                                                        else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g3->m_baAtomType[z3t]])->GetAt(a3->GetAt(z3a)));
1237
 
                                                                                                                                                                        if ((!m_iRefOrSec[1][0]) || (obs == NULL))
1238
 
                                                                                                                                                                                vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g4->m_baAtomType[z4t]])->GetAt(a4->GetAt(z4a)));
1239
 
                                                                                                                                                                                        else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g4->m_baAtomType[z4t]])->GetAt(a4->GetAt(z4a)));
1240
 
                                                                                                                                                                        if ((!m_iRefOrSec[1][1]) || (obs == NULL))
1241
 
                                                                                                                                                                                vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g5->m_baAtomType[z5t]])->GetAt(a5->GetAt(z5a)));
1242
 
                                                                                                                                                                                        else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g5->m_baAtomType[z5t]])->GetAt(a5->GetAt(z5a)));
1243
 
                                                                                                                                                                        vec->Add(0);
1244
 
                                                                                                                                                                        if ((!m_iRefOrSec[2][0]) || (obs == NULL))
1245
 
                                                                                                                                                                                vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g7->m_baAtomType[z7t]])->GetAt(a7->GetAt(z7a)));
1246
 
                                                                                                                                                                                        else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g7->m_baAtomType[z7t]])->GetAt(a7->GetAt(z7a)));
1247
 
                                                                                                                                                                        if ((!m_iRefOrSec[2][1]) || (obs == NULL))
1248
 
                                                                                                                                                                                vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g8->m_baAtomType[z8t]])->GetAt(a8->GetAt(z8a)));
1249
 
                                                                                                                                                                                        else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g8->m_baAtomType[z8t]])->GetAt(a8->GetAt(z8a)));
1250
 
                                                                                                                                                                        if ((!m_iRefOrSec[2][2]) || (obs == NULL))
1251
 
                                                                                                                                                                                vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g9->m_baAtomType[z9t]])->GetAt(a9->GetAt(z9a)));
1252
 
                                                                                                                                                                                        else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g9->m_baAtomType[z9t]])->GetAt(a9->GetAt(z9a)));
1253
 
                                                                                                                                                                }
1254
 
                                                                                                                                                        }
1255
 
                                                                                                                                                }
1256
 
                                                                                                                                        }
1257
 
                                                                                                                                }
1258
 
                                                                                                                        }
1259
 
                                                                                                                } else // IF NOT ORTHO[2]
1260
 
                                                                                                                {
1261
 
                                                                                                                        g7 = (CAtomGroup*)m_oaVectors[z*9+6];
1262
 
                                                                                                                        g8 = (CAtomGroup*)m_oaVectors[z*9+7];
1263
 
                                                                                                                        for (z7t=0;z7t<g7->m_baAtomType.GetSize();z7t++)
1264
 
                                                                                                                        {
1265
 
                                                                                                                                a7 = (CxIntArray*)g7->m_oaAtoms[z7t];
1266
 
                                                                                                                                for (z7a=0;z7a<a7->GetSize();z7a++)
1267
 
                                                                                                                                {
1268
 
                                                                                                                                        for (z8t=0;z8t<g8->m_baAtomType.GetSize();z8t++)
1269
 
                                                                                                                                        {
1270
 
                                                                                                                                                a8 = (CxIntArray*)g8->m_oaAtoms[z8t];
1271
 
                                                                                                                                                for (z8a=0;z8a<a8->GetSize();z8a++)
1272
 
                                                                                                                                                {
1273
 
                                                                                                                                                        if ((!m_iRefOrSec[0][0]) || (obs == NULL))
1274
 
                                                                                                                                                                vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g1->m_baAtomType[z1t]])->GetAt(a1->GetAt(z1a)));
1275
 
                                                                                                                                                                        else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g1->m_baAtomType[z1t]])->GetAt(a1->GetAt(z1a)));
1276
 
                                                                                                                                                        if ((!m_iRefOrSec[0][1]) || (obs == NULL))
1277
 
                                                                                                                                                                vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g2->m_baAtomType[z2t]])->GetAt(a2->GetAt(z2a)));
1278
 
                                                                                                                                                                        else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g2->m_baAtomType[z2t]])->GetAt(a2->GetAt(z2a)));
1279
 
                                                                                                                                                        if ((!m_iRefOrSec[0][2]) || (obs == NULL))
1280
 
                                                                                                                                                                vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g3->m_baAtomType[z3t]])->GetAt(a3->GetAt(z3a)));
1281
 
                                                                                                                                                                        else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g3->m_baAtomType[z3t]])->GetAt(a3->GetAt(z3a)));
1282
 
                                                                                                                                                        if ((!m_iRefOrSec[1][0]) || (obs == NULL))
1283
 
                                                                                                                                                                vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g4->m_baAtomType[z4t]])->GetAt(a4->GetAt(z4a)));
1284
 
                                                                                                                                                                        else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g4->m_baAtomType[z4t]])->GetAt(a4->GetAt(z4a)));
1285
 
                                                                                                                                                        if ((!m_iRefOrSec[1][1]) || (obs == NULL))
1286
 
                                                                                                                                                                vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g5->m_baAtomType[z5t]])->GetAt(a5->GetAt(z5a)));
1287
 
                                                                                                                                                                        else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g5->m_baAtomType[z5t]])->GetAt(a5->GetAt(z5a)));
1288
 
                                                                                                                                                        vec->Add(0);
1289
 
                                                                                                                                                        if ((!m_iRefOrSec[2][0]) || (obs == NULL))
1290
 
                                                                                                                                                                vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g7->m_baAtomType[z7t]])->GetAt(a7->GetAt(z7a)));
1291
 
                                                                                                                                                                        else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g7->m_baAtomType[z7t]])->GetAt(a7->GetAt(z7a)));
1292
 
                                                                                                                                                        if ((!m_iRefOrSec[2][1]) || (obs == NULL))
1293
 
                                                                                                                                                                vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g8->m_baAtomType[z8t]])->GetAt(a8->GetAt(z8a)));
1294
 
                                                                                                                                                                        else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g8->m_baAtomType[z8t]])->GetAt(a8->GetAt(z8a)));
1295
 
                                                                                                                                                        vec->Add(0);
1296
 
                                                                                                                                                }
1297
 
                                                                                                                                        }
1298
 
                                                                                                                                }
1299
 
                                                                                                                        }
1300
 
                                                                                                                } // END IF NOT ORTHO[2]
1301
 
                                                                                                        }
1302
 
                                                                                                }
1303
 
                                                                                        }
1304
 
                                                                                }
1305
 
                                                                        } // END IF NOT ORTHO[1]
1306
 
                                                                }
1307
 
                                                        }
1308
 
                                                }
1309
 
                                        }
1310
 
                                }
1311
 
                        }
1312
 
                } else // IF NOT ORTHO[0]
1313
 
                {
1314
 
                        g1 = (CAtomGroup*)m_oaVectors[z*9];
1315
 
                        g2 = (CAtomGroup*)m_oaVectors[z*9+1];
1316
 
                        for (z1t=0;z1t<g1->m_baAtomType.GetSize();z1t++)
1317
 
                        {
1318
 
                                a1 = (CxIntArray*)g1->m_oaAtoms[z1t];
1319
 
                                for (z1a=0;z1a<a1->GetSize();z1a++)
1320
 
                                {
1321
 
                                        for (z2t=0;z2t<g2->m_baAtomType.GetSize();z2t++)
1322
 
                                        {
1323
 
                                                a2 = (CxIntArray*)g2->m_oaAtoms[z2t];
1324
 
                                                for (z2a=0;z2a<a2->GetSize();z2a++)
1325
 
                                                {
1326
 
                                                        if (m_bOrtho[1])
1327
 
                                                        {
1328
 
                                                                g4 = (CAtomGroup*)m_oaVectors[z*9+3];
1329
 
                                                                g5 = (CAtomGroup*)m_oaVectors[z*9+4];
1330
 
                                                                g6 = (CAtomGroup*)m_oaVectors[z*9+5];
1331
 
                                                                for (z4t=0;z4t<g4->m_baAtomType.GetSize();z4t++)
1332
 
                                                                {
1333
 
                                                                        a4 = (CxIntArray*)g4->m_oaAtoms[z4t];
1334
 
                                                                        for (z4a=0;z4a<a4->GetSize();z4a++)
1335
 
                                                                        {
1336
 
                                                                                for (z5t=0;z5t<g5->m_baAtomType.GetSize();z5t++)
1337
 
                                                                                {
1338
 
                                                                                        a5 = (CxIntArray*)g5->m_oaAtoms[z5t];
1339
 
                                                                                        for (z5a=0;z5a<a5->GetSize();z5a++)
1340
 
                                                                                        {
1341
 
                                                                                                for (z6t=0;z6t<g6->m_baAtomType.GetSize();z6t++)
1342
 
                                                                                                {
1343
 
                                                                                                        a6 = (CxIntArray*)g6->m_oaAtoms[z6t];
1344
 
                                                                                                        for (z6a=0;z6a<a6->GetSize();z6a++)
1345
 
                                                                                                        {
1346
 
                                                                                                                if (m_bOrtho[2])
1347
 
                                                                                                                {
1348
 
                                                                                                                        g7 = (CAtomGroup*)m_oaVectors[z*9+6];
1349
 
                                                                                                                        g8 = (CAtomGroup*)m_oaVectors[z*9+7];
1350
 
                                                                                                                        g9 = (CAtomGroup*)m_oaVectors[z*9+8];
1351
 
                                                                                                                        for (z7t=0;z7t<g7->m_baAtomType.GetSize();z7t++)
1352
 
                                                                                                                        {
1353
 
                                                                                                                                a7 = (CxIntArray*)g7->m_oaAtoms[z7t];
1354
 
                                                                                                                                for (z7a=0;z7a<a7->GetSize();z7a++)
1355
 
                                                                                                                                {
1356
 
                                                                                                                                        for (z8t=0;z8t<g8->m_baAtomType.GetSize();z8t++)
1357
 
                                                                                                                                        {
1358
 
                                                                                                                                                a8 = (CxIntArray*)g8->m_oaAtoms[z8t];
1359
 
                                                                                                                                                for (z8a=0;z8a<a8->GetSize();z8a++)
1360
 
                                                                                                                                                {
1361
 
                                                                                                                                                        for (z9t=0;z9t<g9->m_baAtomType.GetSize();z9t++)
1362
 
                                                                                                                                                        {
1363
 
                                                                                                                                                                a9 = (CxIntArray*)g9->m_oaAtoms[z9t];
1364
 
                                                                                                                                                                for (z9a=0;z9a<a9->GetSize();z9a++)
1365
 
                                                                                                                                                                {
1366
 
                                                                                                                                                                        if ((!m_iRefOrSec[0][0]) || (obs == NULL))
1367
 
                                                                                                                                                                                vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g1->m_baAtomType[z1t]])->GetAt(a1->GetAt(z1a)));
1368
 
                                                                                                                                                                                        else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g1->m_baAtomType[z1t]])->GetAt(a1->GetAt(z1a)));
1369
 
                                                                                                                                                                        if ((!m_iRefOrSec[0][1]) || (obs == NULL))
1370
 
                                                                                                                                                                                vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g2->m_baAtomType[z2t]])->GetAt(a2->GetAt(z2a)));
1371
 
                                                                                                                                                                                        else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g2->m_baAtomType[z2t]])->GetAt(a2->GetAt(z2a)));
1372
 
                                                                                                                                                                        vec->Add(0);
1373
 
                                                                                                                                                                        if ((!m_iRefOrSec[1][0]) || (obs == NULL))
1374
 
                                                                                                                                                                                vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g4->m_baAtomType[z4t]])->GetAt(a4->GetAt(z4a)));
1375
 
                                                                                                                                                                                        else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g4->m_baAtomType[z4t]])->GetAt(a4->GetAt(z4a)));
1376
 
                                                                                                                                                                        if ((!m_iRefOrSec[1][1]) || (obs == NULL))
1377
 
                                                                                                                                                                                vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g5->m_baAtomType[z5t]])->GetAt(a5->GetAt(z5a)));
1378
 
                                                                                                                                                                                        else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g5->m_baAtomType[z5t]])->GetAt(a5->GetAt(z5a)));
1379
 
                                                                                                                                                                        if ((!m_iRefOrSec[1][2]) || (obs == NULL))
1380
 
                                                                                                                                                                                vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g6->m_baAtomType[z6t]])->GetAt(a6->GetAt(z6a)));
1381
 
                                                                                                                                                                                        else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g6->m_baAtomType[z6t]])->GetAt(a6->GetAt(z6a)));
1382
 
                                                                                                                                                                        if ((!m_iRefOrSec[2][0]) || (obs == NULL))
1383
 
                                                                                                                                                                                vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g7->m_baAtomType[z7t]])->GetAt(a7->GetAt(z7a)));
1384
 
                                                                                                                                                                                        else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g7->m_baAtomType[z7t]])->GetAt(a7->GetAt(z7a)));
1385
 
                                                                                                                                                                        if ((!m_iRefOrSec[2][1]) || (obs == NULL))
1386
 
                                                                                                                                                                                vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g8->m_baAtomType[z8t]])->GetAt(a8->GetAt(z8a)));
1387
 
                                                                                                                                                                                        else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g8->m_baAtomType[z8t]])->GetAt(a8->GetAt(z8a)));
1388
 
                                                                                                                                                                        if ((!m_iRefOrSec[2][2]) || (obs == NULL))
1389
 
                                                                                                                                                                                vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g9->m_baAtomType[z9t]])->GetAt(a9->GetAt(z9a)));
1390
 
                                                                                                                                                                                        else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g9->m_baAtomType[z9t]])->GetAt(a9->GetAt(z9a)));
1391
 
                                                                                                                                                                }
1392
 
                                                                                                                                                        }
1393
 
                                                                                                                                                }
1394
 
                                                                                                                                        }
1395
 
                                                                                                                                }
1396
 
                                                                                                                        }
1397
 
                                                                                                                } else // IF NOT ORTHO[2]
1398
 
                                                                                                                {
1399
 
                                                                                                                        g7 = (CAtomGroup*)m_oaVectors[z*9+6];
1400
 
                                                                                                                        g8 = (CAtomGroup*)m_oaVectors[z*9+7];
1401
 
                                                                                                                        for (z7t=0;z7t<g7->m_baAtomType.GetSize();z7t++)
1402
 
                                                                                                                        {
1403
 
                                                                                                                                a7 = (CxIntArray*)g7->m_oaAtoms[z7t];
1404
 
                                                                                                                                for (z7a=0;z7a<a7->GetSize();z7a++)
1405
 
                                                                                                                                {
1406
 
                                                                                                                                        for (z8t=0;z8t<g8->m_baAtomType.GetSize();z8t++)
1407
 
                                                                                                                                        {
1408
 
                                                                                                                                                a8 = (CxIntArray*)g8->m_oaAtoms[z8t];
1409
 
                                                                                                                                                for (z8a=0;z8a<a8->GetSize();z8a++)
1410
 
                                                                                                                                                {
1411
 
                                                                                                                                                        if ((!m_iRefOrSec[0][0]) || (obs == NULL))
1412
 
                                                                                                                                                                vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g1->m_baAtomType[z1t]])->GetAt(a1->GetAt(z1a)));
1413
 
                                                                                                                                                                        else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g1->m_baAtomType[z1t]])->GetAt(a1->GetAt(z1a)));
1414
 
                                                                                                                                                        if ((!m_iRefOrSec[0][1]) || (obs == NULL))
1415
 
                                                                                                                                                                vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g2->m_baAtomType[z2t]])->GetAt(a2->GetAt(z2a)));
1416
 
                                                                                                                                                                        else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g2->m_baAtomType[z2t]])->GetAt(a2->GetAt(z2a)));
1417
 
                                                                                                                                                        vec->Add(0);
1418
 
                                                                                                                                                        if ((!m_iRefOrSec[1][0]) || (obs == NULL))
1419
 
                                                                                                                                                                vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g4->m_baAtomType[z4t]])->GetAt(a4->GetAt(z4a)));
1420
 
                                                                                                                                                                        else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g4->m_baAtomType[z4t]])->GetAt(a4->GetAt(z4a)));
1421
 
                                                                                                                                                        if ((!m_iRefOrSec[1][1]) || (obs == NULL))
1422
 
                                                                                                                                                                vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g5->m_baAtomType[z5t]])->GetAt(a5->GetAt(z5a)));
1423
 
                                                                                                                                                                        else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g5->m_baAtomType[z5t]])->GetAt(a5->GetAt(z5a)));
1424
 
                                                                                                                                                        if ((!m_iRefOrSec[1][2]) || (obs == NULL))
1425
 
                                                                                                                                                                vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g6->m_baAtomType[z6t]])->GetAt(a6->GetAt(z6a)));
1426
 
                                                                                                                                                                        else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g6->m_baAtomType[z6t]])->GetAt(a6->GetAt(z6a)));
1427
 
                                                                                                                                                        if ((!m_iRefOrSec[2][0]) || (obs == NULL))
1428
 
                                                                                                                                                                vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g7->m_baAtomType[z7t]])->GetAt(a7->GetAt(z7a)));
1429
 
                                                                                                                                                                        else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g7->m_baAtomType[z7t]])->GetAt(a7->GetAt(z7a)));
1430
 
                                                                                                                                                        if ((!m_iRefOrSec[2][1]) || (obs == NULL))
1431
 
                                                                                                                                                                vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g8->m_baAtomType[z8t]])->GetAt(a8->GetAt(z8a)));
1432
 
                                                                                                                                                                        else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g8->m_baAtomType[z8t]])->GetAt(a8->GetAt(z8a)));
1433
 
                                                                                                                                                        vec->Add(0);
1434
 
                                                                                                                                                }
1435
 
                                                                                                                                        }
1436
 
                                                                                                                                }
1437
 
                                                                                                                        }
1438
 
                                                                                                                } // END IF NOT ORTHO[2]
1439
 
                                                                                                        }
1440
 
                                                                                                }
1441
 
                                                                                        }
1442
 
                                                                                }
1443
 
                                                                        }
1444
 
                                                                }
1445
 
                                                        } else // IF NOT ORTHO[1]
1446
 
                                                        {
1447
 
                                                                g4 = (CAtomGroup*)m_oaVectors[z*9+3];
1448
 
                                                                g5 = (CAtomGroup*)m_oaVectors[z*9+4];
1449
 
                                                                for (z4t=0;z4t<g4->m_baAtomType.GetSize();z4t++)
1450
 
                                                                {
1451
 
                                                                        a4 = (CxIntArray*)g4->m_oaAtoms[z4t];
1452
 
                                                                        for (z4a=0;z4a<a4->GetSize();z4a++)
1453
 
                                                                        {
1454
 
                                                                                for (z5t=0;z5t<g5->m_baAtomType.GetSize();z5t++)
1455
 
                                                                                {
1456
 
                                                                                        a5 = (CxIntArray*)g5->m_oaAtoms[z5t];
1457
 
                                                                                        for (z5a=0;z5a<a5->GetSize();z5a++)
1458
 
                                                                                        {
1459
 
                                                                                                if (m_bOrtho[2])
1460
 
                                                                                                {
1461
 
                                                                                                        g7 = (CAtomGroup*)m_oaVectors[z*9+6];
1462
 
                                                                                                        g8 = (CAtomGroup*)m_oaVectors[z*9+7];
1463
 
                                                                                                        g9 = (CAtomGroup*)m_oaVectors[z*9+8];
1464
 
                                                                                                        for (z7t=0;z7t<g7->m_baAtomType.GetSize();z7t++)
1465
 
                                                                                                        {
1466
 
                                                                                                                a7 = (CxIntArray*)g7->m_oaAtoms[z7t];
1467
 
                                                                                                                for (z7a=0;z7a<a7->GetSize();z7a++)
1468
 
                                                                                                                {
1469
 
                                                                                                                        for (z8t=0;z8t<g8->m_baAtomType.GetSize();z8t++)
1470
 
                                                                                                                        {
1471
 
                                                                                                                                a8 = (CxIntArray*)g8->m_oaAtoms[z8t];
1472
 
                                                                                                                                for (z8a=0;z8a<a8->GetSize();z8a++)
1473
 
                                                                                                                                {
1474
 
                                                                                                                                        for (z9t=0;z9t<g9->m_baAtomType.GetSize();z9t++)
1475
 
                                                                                                                                        {
1476
 
                                                                                                                                                a9 = (CxIntArray*)g9->m_oaAtoms[z9t];
1477
 
                                                                                                                                                for (z9a=0;z9a<a9->GetSize();z9a++)
1478
 
                                                                                                                                                {
1479
 
                                                                                                                                                        if ((!m_iRefOrSec[0][0]) || (obs == NULL))
1480
 
                                                                                                                                                                vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g1->m_baAtomType[z1t]])->GetAt(a1->GetAt(z1a)));
1481
 
                                                                                                                                                                        else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g1->m_baAtomType[z1t]])->GetAt(a1->GetAt(z1a)));
1482
 
                                                                                                                                                        if ((!m_iRefOrSec[0][1]) || (obs == NULL))
1483
 
                                                                                                                                                                vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g2->m_baAtomType[z2t]])->GetAt(a2->GetAt(z2a)));
1484
 
                                                                                                                                                                        else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g2->m_baAtomType[z2t]])->GetAt(a2->GetAt(z2a)));
1485
 
                                                                                                                                                        vec->Add(0);
1486
 
                                                                                                                                                        if ((!m_iRefOrSec[1][0]) || (obs == NULL))
1487
 
                                                                                                                                                                vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g4->m_baAtomType[z4t]])->GetAt(a4->GetAt(z4a)));
1488
 
                                                                                                                                                                        else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g4->m_baAtomType[z4t]])->GetAt(a4->GetAt(z4a)));
1489
 
                                                                                                                                                        if ((!m_iRefOrSec[1][1]) || (obs == NULL))
1490
 
                                                                                                                                                                vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g5->m_baAtomType[z5t]])->GetAt(a5->GetAt(z5a)));
1491
 
                                                                                                                                                                        else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g5->m_baAtomType[z5t]])->GetAt(a5->GetAt(z5a)));
1492
 
                                                                                                                                                        vec->Add(0);
1493
 
                                                                                                                                                        if ((!m_iRefOrSec[2][0]) || (obs == NULL))
1494
 
                                                                                                                                                                vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g7->m_baAtomType[z7t]])->GetAt(a7->GetAt(z7a)));
1495
 
                                                                                                                                                                        else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g7->m_baAtomType[z7t]])->GetAt(a7->GetAt(z7a)));
1496
 
                                                                                                                                                        if ((!m_iRefOrSec[2][1]) || (obs == NULL))
1497
 
                                                                                                                                                                vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g8->m_baAtomType[z8t]])->GetAt(a8->GetAt(z8a)));
1498
 
                                                                                                                                                                        else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g8->m_baAtomType[z8t]])->GetAt(a8->GetAt(z8a)));
1499
 
                                                                                                                                                        if ((!m_iRefOrSec[2][2]) || (obs == NULL))
1500
 
                                                                                                                                                                vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g9->m_baAtomType[z9t]])->GetAt(a9->GetAt(z9a)));
1501
 
                                                                                                                                                                        else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g9->m_baAtomType[z9t]])->GetAt(a9->GetAt(z9a)));
1502
 
                                                                                                                                                }
1503
 
                                                                                                                                        }
1504
 
                                                                                                                                }
1505
 
                                                                                                                        }
1506
 
                                                                                                                }
1507
 
                                                                                                        }
1508
 
                                                                                                } else // IF NOT ORTHO[2]
1509
 
                                                                                                {
1510
 
                                                                                                        g7 = (CAtomGroup*)m_oaVectors[z*9+6];
1511
 
                                                                                                        g8 = (CAtomGroup*)m_oaVectors[z*9+7];
1512
 
                                                                                                        for (z7t=0;z7t<g7->m_baAtomType.GetSize();z7t++)
1513
 
                                                                                                        {
1514
 
                                                                                                                a7 = (CxIntArray*)g7->m_oaAtoms[z7t];
1515
 
                                                                                                                for (z7a=0;z7a<a7->GetSize();z7a++)
1516
 
                                                                                                                {
1517
 
                                                                                                                        for (z8t=0;z8t<g8->m_baAtomType.GetSize();z8t++)
1518
 
                                                                                                                        {
1519
 
                                                                                                                                a8 = (CxIntArray*)g8->m_oaAtoms[z8t];
1520
 
                                                                                                                                for (z8a=0;z8a<a8->GetSize();z8a++)
1521
 
                                                                                                                                {
1522
 
                                                                                                                                        if ((!m_iRefOrSec[0][0]) || (obs == NULL))
1523
 
                                                                                                                                                vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g1->m_baAtomType[z1t]])->GetAt(a1->GetAt(z1a)));
1524
 
                                                                                                                                                        else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g1->m_baAtomType[z1t]])->GetAt(a1->GetAt(z1a)));
1525
 
                                                                                                                                        if ((!m_iRefOrSec[0][1]) || (obs == NULL))
1526
 
                                                                                                                                                vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g2->m_baAtomType[z2t]])->GetAt(a2->GetAt(z2a)));
1527
 
                                                                                                                                                        else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g2->m_baAtomType[z2t]])->GetAt(a2->GetAt(z2a)));
1528
 
                                                                                                                                        vec->Add(0);
1529
 
                                                                                                                                        if ((!m_iRefOrSec[1][0]) || (obs == NULL))
1530
 
                                                                                                                                                vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g4->m_baAtomType[z4t]])->GetAt(a4->GetAt(z4a)));
1531
 
                                                                                                                                                        else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g4->m_baAtomType[z4t]])->GetAt(a4->GetAt(z4a)));
1532
 
                                                                                                                                        if ((!m_iRefOrSec[1][1]) || (obs == NULL))
1533
 
                                                                                                                                                vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g5->m_baAtomType[z5t]])->GetAt(a5->GetAt(z5a)));
1534
 
                                                                                                                                                        else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g5->m_baAtomType[z5t]])->GetAt(a5->GetAt(z5a)));
1535
 
                                                                                                                                        vec->Add(0);
1536
 
                                                                                                                                        if ((!m_iRefOrSec[2][0]) || (obs == NULL))
1537
 
                                                                                                                                                vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g7->m_baAtomType[z7t]])->GetAt(a7->GetAt(z7a)));
1538
 
                                                                                                                                                        else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g7->m_baAtomType[z7t]])->GetAt(a7->GetAt(z7a)));
1539
 
                                                                                                                                        if ((!m_iRefOrSec[2][1]) || (obs == NULL))
1540
 
                                                                                                                                                vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g8->m_baAtomType[z8t]])->GetAt(a8->GetAt(z8a)));
1541
 
                                                                                                                                                        else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g8->m_baAtomType[z8t]])->GetAt(a8->GetAt(z8a)));
1542
 
                                                                                                                                        vec->Add(0);
1543
 
                                                                                                                                }
1544
 
                                                                                                                        }
1545
 
                                                                                                                }
1546
 
                                                                                                        }
1547
 
                                                                                                } // END IF NOT ORTHO[2]
1548
 
                                                                                        }
1549
 
                                                                                }
1550
 
                                                                        }
1551
 
                                                                }
1552
 
                                                        } // END IF NOT ORTHO[1]
1553
 
                                                }
1554
 
                                        }
1555
 
                                }
1556
 
                        }
1557
 
                } // END IF NOT ORTHO[0]
1558
 
        } // END FOR ALL SETS
1559
 
        BXOUT;
1560
 
}
1561
 
 
1562
 
 
1563
 
void CPlDF::BuildAtomList(CSingleMolecule *ref, CSingleMolecule *obs, CxIntArray *vec)
1564
 
{
1565
 
        BXIN;
1566
 
        int z, z1t, z1a, z2t, z2a, z3t, z3a, z4t, z4a;
1567
 
        CAtomGroup *g1, *g2, *g3, *g4;
1568
 
        CxIntArray *a1, *a2, *a3, *a4;
1569
 
 
1570
 
        vec->RemoveAll_KeepSize();
1571
 
        for (z=0;z<m_oaVectors.GetSize()/4;z++)
1572
 
        {
1573
 
                if (m_bNormal)
1574
 
                {
1575
 
                        g1 = (CAtomGroup*)m_oaVectors[z*4];
1576
 
                        g2 = (CAtomGroup*)m_oaVectors[z*4+1];
1577
 
                        g4 = (CAtomGroup*)m_oaVectors[z*4+3];
1578
 
 
1579
 
                        for (z1t=0;z1t<g1->m_baAtomType.GetSize();z1t++)
1580
 
                        {
1581
 
                                a1 = (CxIntArray*)g1->m_oaAtoms[z1t];
1582
 
                                for (z1a=0;z1a<a1->GetSize();z1a++)
1583
 
                                {
1584
 
                                        for (z2t=0;z2t<g2->m_baAtomType.GetSize();z2t++)
1585
 
                                        {
1586
 
                                                a2 = (CxIntArray*)g2->m_oaAtoms[z2t];
1587
 
                                                for (z2a=0;z2a<a2->GetSize();z2a++)
1588
 
                                                {
1589
 
                                                        for (z4t=0;z4t<g4->m_baAtomType.GetSize();z4t++)
1590
 
                                                        {
1591
 
                                                                a4 = (CxIntArray*)g4->m_oaAtoms[z4t];
1592
 
                                                                for (z4a=0;z4a<a4->GetSize();z4a++)
1593
 
                                                                {
1594
 
                                                                        if ((!m_iRefOrSec[0]) || (obs == NULL))
1595
 
                                                                                vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g1->m_baAtomType[z1t]])->GetAt(a1->GetAt(z1a)));
1596
 
                                                                                        else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g1->m_baAtomType[z1t]])->GetAt(a1->GetAt(z1a)));
1597
 
                                                                        if ((!m_iRefOrSec[1]) || (obs == NULL))
1598
 
                                                                                vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g2->m_baAtomType[z2t]])->GetAt(a2->GetAt(z2a)));
1599
 
                                                                                        else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g2->m_baAtomType[z2t]])->GetAt(a2->GetAt(z2a)));
1600
 
                                                                        vec->Add(0);
1601
 
                                                                        if ((!m_iRefOrSec[3]) || (obs == NULL))
1602
 
                                                                                vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g4->m_baAtomType[z4t]])->GetAt(a4->GetAt(z4a)));
1603
 
                                                                                        else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g4->m_baAtomType[z4t]])->GetAt(a4->GetAt(z4a)));
1604
 
                                                                }
1605
 
                                                        }
1606
 
                                                }
1607
 
                                        }
1608
 
                                }
1609
 
                        }
1610
 
                } else // IF NOT NORMAL
1611
 
                {
1612
 
                        g1 = (CAtomGroup*)m_oaVectors[z*4];
1613
 
                        g2 = (CAtomGroup*)m_oaVectors[z*4+1];
1614
 
                        g3 = (CAtomGroup*)m_oaVectors[z*4+2];
1615
 
                        g4 = (CAtomGroup*)m_oaVectors[z*4+3];
1616
 
 
1617
 
                        for (z1t=0;z1t<g1->m_baAtomType.GetSize();z1t++)
1618
 
                        {
1619
 
                                a1 = (CxIntArray*)g1->m_oaAtoms[z1t];
1620
 
                                for (z1a=0;z1a<a1->GetSize();z1a++)
1621
 
                                {
1622
 
                                        for (z2t=0;z2t<g2->m_baAtomType.GetSize();z2t++)
1623
 
                                        {
1624
 
                                                a2 = (CxIntArray*)g2->m_oaAtoms[z2t];
1625
 
                                                for (z2a=0;z2a<a2->GetSize();z2a++)
1626
 
                                                {
1627
 
                                                        for (z3t=0;z3t<g3->m_baAtomType.GetSize();z3t++)
1628
 
                                                        {
1629
 
                                                                a3 = (CxIntArray*)g3->m_oaAtoms[z3t];
1630
 
                                                                for (z3a=0;z3a<a3->GetSize();z3a++)
1631
 
                                                                {
1632
 
                                                                        for (z4t=0;z4t<g4->m_baAtomType.GetSize();z4t++)
1633
 
                                                                        {
1634
 
                                                                                a4 = (CxIntArray*)g4->m_oaAtoms[z4t];
1635
 
                                                                                for (z4a=0;z4a<a4->GetSize();z4a++)
1636
 
                                                                                {
1637
 
                                                                                        if ((!m_iRefOrSec[0]) || (obs == NULL))
1638
 
                                                                                                vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g1->m_baAtomType[z1t]])->GetAt(a1->GetAt(z1a)));
1639
 
                                                                                                        else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g1->m_baAtomType[z1t]])->GetAt(a1->GetAt(z1a)));
1640
 
                                                                                        if ((!m_iRefOrSec[1]) || (obs == NULL))
1641
 
                                                                                                vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g2->m_baAtomType[z2t]])->GetAt(a2->GetAt(z2a)));
1642
 
                                                                                                        else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g2->m_baAtomType[z2t]])->GetAt(a2->GetAt(z2a)));
1643
 
                                                                                        if ((!m_iRefOrSec[2]) || (obs == NULL))
1644
 
                                                                                                vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g3->m_baAtomType[z3t]])->GetAt(a3->GetAt(z3a)));
1645
 
                                                                                                        else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g3->m_baAtomType[z3t]])->GetAt(a3->GetAt(z3a)));
1646
 
                                                                                        if ((!m_iRefOrSec[3]) || (obs == NULL))
1647
 
                                                                                                vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g4->m_baAtomType[z4t]])->GetAt(a4->GetAt(z4a)));
1648
 
                                                                                                        else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g4->m_baAtomType[z4t]])->GetAt(a4->GetAt(z4a)));
1649
 
                                                                                }
1650
 
                                                                        }
1651
 
                                                                }
1652
 
                                                        }
1653
 
                                                }
1654
 
                                        }
1655
 
                                }
1656
 
                        }
1657
 
                }
1658
 
        } // END FOR ALL SETS
1659
 
        BXOUT;
1660
 
}
1661
 
 
1662
 
 
1663
 
void CLiDF::BuildAtomList(CSingleMolecule *ref, CSingleMolecule *obs, CxIntArray *vec)
1664
 
{
1665
 
        BXIN;
1666
 
        int z, z1t, z1a, z2t, z2a, z3t, z3a, z4t, z4a;
1667
 
        CAtomGroup *g1, *g2, *g3, *g4;
1668
 
        CxIntArray *a1, *a2, *a3, *a4;
1669
 
 
1670
 
        vec->RemoveAll_KeepSize();
1671
 
        for (z=0;z<m_oaVectors.GetSize()/4;z++)
1672
 
        {
1673
 
                if (m_bNormal)
1674
 
                {
1675
 
                        g1 = (CAtomGroup*)m_oaVectors[z*4];
1676
 
                        g2 = (CAtomGroup*)m_oaVectors[z*4+1];
1677
 
                        g3 = (CAtomGroup*)m_oaVectors[z*4+2];
1678
 
                        g4 = (CAtomGroup*)m_oaVectors[z*4+3];
1679
 
 
1680
 
                        for (z1t=0;z1t<g1->m_baAtomType.GetSize();z1t++)
1681
 
                        {
1682
 
                                a1 = (CxIntArray*)g1->m_oaAtoms[z1t];
1683
 
                                for (z1a=0;z1a<a1->GetSize();z1a++)
1684
 
                                {
1685
 
                                        for (z2t=0;z2t<g2->m_baAtomType.GetSize();z2t++)
1686
 
                                        {
1687
 
                                                a2 = (CxIntArray*)g2->m_oaAtoms[z2t];
1688
 
                                                for (z2a=0;z2a<a2->GetSize();z2a++)
1689
 
                                                {
1690
 
                                                        for (z3t=0;z3t<g3->m_baAtomType.GetSize();z3t++)
1691
 
                                                        {
1692
 
                                                                a3 = (CxIntArray*)g3->m_oaAtoms[z3t];
1693
 
                                                                for (z3a=0;z3a<a3->GetSize();z3a++)
1694
 
                                                                {
1695
 
                                                                        for (z4t=0;z4t<g4->m_baAtomType.GetSize();z4t++)
1696
 
                                                                        {
1697
 
                                                                                a4 = (CxIntArray*)g4->m_oaAtoms[z4t];
1698
 
                                                                                for (z4a=0;z4a<a4->GetSize();z4a++)
1699
 
                                                                                {
1700
 
                                                                                        if ((!m_iRefOrSec[0]) || (obs == NULL))
1701
 
                                                                                                vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g1->m_baAtomType[z1t]])->GetAt(a1->GetAt(z1a)));
1702
 
                                                                                                        else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g1->m_baAtomType[z1t]])->GetAt(a1->GetAt(z1a)));
1703
 
                                                                                        if ((!m_iRefOrSec[1]) || (obs == NULL))
1704
 
                                                                                                vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g2->m_baAtomType[z2t]])->GetAt(a2->GetAt(z2a)));
1705
 
                                                                                                        else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g2->m_baAtomType[z2t]])->GetAt(a2->GetAt(z2a)));
1706
 
                                                                                        if ((!m_iRefOrSec[2]) || (obs == NULL))
1707
 
                                                                                                vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g3->m_baAtomType[z3t]])->GetAt(a3->GetAt(z3a)));
1708
 
                                                                                                        else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g3->m_baAtomType[z3t]])->GetAt(a3->GetAt(z3a)));
1709
 
                                                                                        if ((!m_iRefOrSec[3]) || (obs == NULL))
1710
 
                                                                                                vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g4->m_baAtomType[z4t]])->GetAt(a4->GetAt(z4a)));
1711
 
                                                                                                        else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g4->m_baAtomType[z4t]])->GetAt(a4->GetAt(z4a)));
1712
 
                                                                                }
1713
 
                                                                        }
1714
 
                                                                }
1715
 
                                                        }
1716
 
                                                }
1717
 
                                        }
1718
 
                                }
1719
 
                        }
1720
 
                } else // If not Normal
1721
 
                {
1722
 
                        g1 = (CAtomGroup*)m_oaVectors[z*4];
1723
 
                        g2 = (CAtomGroup*)m_oaVectors[z*4+1];
1724
 
                        g4 = (CAtomGroup*)m_oaVectors[z*4+3];
1725
 
 
1726
 
                        for (z1t=0;z1t<g1->m_baAtomType.GetSize();z1t++)
1727
 
                        {
1728
 
                                a1 = (CxIntArray*)g1->m_oaAtoms[z1t];
1729
 
                                for (z1a=0;z1a<a1->GetSize();z1a++)
1730
 
                                {
1731
 
                                        for (z2t=0;z2t<g2->m_baAtomType.GetSize();z2t++)
1732
 
                                        {
1733
 
                                                a2 = (CxIntArray*)g2->m_oaAtoms[z2t];
1734
 
                                                for (z2a=0;z2a<a2->GetSize();z2a++)
1735
 
                                                {
1736
 
                                                        for (z4t=0;z4t<g4->m_baAtomType.GetSize();z4t++)
1737
 
                                                        {
1738
 
                                                                a4 = (CxIntArray*)g4->m_oaAtoms[z4t];
1739
 
                                                                for (z4a=0;z4a<a4->GetSize();z4a++)
1740
 
                                                                {
1741
 
                                                                        if ((!m_iRefOrSec[0]) || (obs == NULL))
1742
 
                                                                                vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g1->m_baAtomType[z1t]])->GetAt(a1->GetAt(z1a)));
1743
 
                                                                                        else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g1->m_baAtomType[z1t]])->GetAt(a1->GetAt(z1a)));
1744
 
                                                                        if ((!m_iRefOrSec[1]) || (obs == NULL))
1745
 
                                                                                vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g2->m_baAtomType[z2t]])->GetAt(a2->GetAt(z2a)));
1746
 
                                                                                        else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g2->m_baAtomType[z2t]])->GetAt(a2->GetAt(z2a)));
1747
 
                                                                        vec->Add(0);
1748
 
                                                                        if ((!m_iRefOrSec[3]) || (obs == NULL))
1749
 
                                                                                vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g4->m_baAtomType[z4t]])->GetAt(a4->GetAt(z4a)));
1750
 
                                                                                        else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g4->m_baAtomType[z4t]])->GetAt(a4->GetAt(z4a)));
1751
 
                                                                }
1752
 
                                                        }
1753
 
                                                }
1754
 
                                        }
1755
 
                                }
1756
 
                        }
1757
 
                }
1758
 
        } // END FOR ALL SETS
1759
 
        BXOUT;
1760
 
}
1761
 
 
1762
 
 
1763
 
void CRDF::BuildName()
1764
 
{
1765
 
        BTIN;
1766
 
        int z;
1767
 
        char tmp[256];
1768
 
 
1769
 
        tmp[0] = 0;
1770
 
        if (m_iDeriv != 0)
1771
 
                sprintf(tmp,"deriv%d_",m_iDeriv);
1772
 
        for (z=0;z<m_oaVectors.GetSize()/2;z++)
1773
 
        {
1774
 
                strcat(tmp,"[");
1775
 
 
1776
 
                strcat(tmp,((CAtomGroup*)m_oaVectors[z*2])->m_sName);
1777
 
                if (m_iRefOrSec[0])
1778
 
                        strcat(tmp,"o_");
1779
 
                                else strcat(tmp,"r_");
1780
 
                strcat(tmp,((CAtomGroup*)m_oaVectors[z*2+1])->m_sName);
1781
 
                if (m_iRefOrSec[1])
1782
 
                        strcat(tmp,"o");
1783
 
                                else strcat(tmp,"r");
1784
 
 
1785
 
                if (z < (m_oaVectors.GetSize()/2)-1)
1786
 
                        strcat(tmp,"],");
1787
 
                                else strcat(tmp,"]");
1788
 
        }
1789
 
 
1790
 
        try { m_sShortName = new char[strlen(tmp)+1]; } catch(...) { m_sShortName = NULL; }
1791
 
        if (m_sShortName == NULL) NewException((double)(strlen(tmp)+1)*sizeof(char),__FILE__,__LINE__,__PRETTY_FUNCTION__);
1792
 
        
1793
 
        strcpy(m_sShortName,tmp);
1794
 
        if (m_iShowMol != -1)
1795
 
                sprintf(tmp,"%s_%s%d_%s_",((CMolecule*)g_oaMolecules[g_iFixMol])->m_sName,((CAtom*)g_oaAtoms[g_iFixRealAtomType[0]])->m_sName,g_iFixAtom[0]+1,((CMolecule*)g_oaMolecules[m_iShowMol])->m_sName);
1796
 
                        else sprintf(tmp,"%s_%s%d_",((CMolecule*)g_oaMolecules[g_iFixMol])->m_sName,((CAtom*)g_oaAtoms[g_iFixRealAtomType[0]])->m_sName,g_iFixAtom[0]+1);
1797
 
        strcat(tmp,m_sShortName);
1798
 
 
1799
 
        try { m_sName = new char[strlen(tmp)+1]; } catch(...) { m_sName = NULL; }
1800
 
        if (m_sName == NULL) NewException((double)(strlen(tmp)+1)*sizeof(char),__FILE__,__LINE__,__PRETTY_FUNCTION__);
1801
 
        
1802
 
        strcpy(m_sName,tmp);
1803
 
 
1804
 
        BTOUT;
1805
 
}
1806
 
 
1807
 
 
1808
 
void CDensDF::BuildName()
1809
 
{
1810
 
        BTIN;
1811
 
        char tmp[256];
1812
 
        int z;
1813
 
 
1814
 
        sprintf(tmp,"%s_%s%d_%s",((CMolecule*)g_oaMolecules[m_iShowMol])->m_sName,((CAtom*)g_oaAtoms[m_iCenterAtomRealType])->m_sName,m_iCenterAtom+1,(m_bDensityMass?"mass":"particle"));
1815
 
 
1816
 
        for (z=0;z<g_oaMolecules.GetSize();z++)
1817
 
        {
1818
 
                if (!m_pDensityMolSelect[z])
1819
 
                        continue;
1820
 
                strcat(tmp,"_");
1821
 
                strcat(tmp,((CMolecule*)g_oaMolecules[z])->m_sName);
1822
 
                if (!m_pDensityMolAG[z]->m_bAllAtoms)
1823
 
                {
1824
 
                        strcat(tmp,"_");
1825
 
                        strcat(tmp,m_pDensityMolAG[z]->m_sName);
1826
 
                }
1827
 
        }
1828
 
 
1829
 
        try { m_sName = new char[strlen(tmp)+1]; } catch(...) { m_sName = NULL; }
1830
 
        if (m_sName == NULL) NewException((double)(strlen(tmp)+1)*sizeof(char),__FILE__,__LINE__,__PRETTY_FUNCTION__);
1831
 
        
1832
 
        strcpy(m_sName,tmp);
1833
 
        BTOUT;
1834
 
}
1835
 
 
1836
 
 
1837
 
void CVHDF::BuildName()
1838
 
{
1839
 
        BTIN;
1840
 
        int z;
1841
 
        char tmp[256];
1842
 
 
1843
 
        tmp[0] = 0;
1844
 
        for (z=0;z<m_oaVectors.GetSize()/2;z++)
1845
 
        {
1846
 
                strcat(tmp,"[");
1847
 
 
1848
 
                strcat(tmp,((CAtomGroup*)m_oaVectors[z*2])->m_sName);
1849
 
                if (m_iRefOrSec[0])
1850
 
                        strcat(tmp,"o_");
1851
 
                                else strcat(tmp,"r_");
1852
 
                strcat(tmp,((CAtomGroup*)m_oaVectors[z*2+1])->m_sName);
1853
 
                if (m_iRefOrSec[1])
1854
 
                        strcat(tmp,"o");
1855
 
                                else strcat(tmp,"r");
1856
 
 
1857
 
                if (z < (m_oaVectors.GetSize()/2)-1)
1858
 
                        strcat(tmp,"],");
1859
 
                                else strcat(tmp,"]");
1860
 
        }
1861
 
 
1862
 
        try { m_sShortName = new char[strlen(tmp)+1]; } catch(...) { m_sShortName = NULL; }
1863
 
        if (m_sShortName == NULL) NewException((double)(strlen(tmp)+1)*sizeof(char),__FILE__,__LINE__,__PRETTY_FUNCTION__);
1864
 
        
1865
 
        strcpy(m_sShortName,tmp);
1866
 
        if (m_iShowMol != -1)
1867
 
                sprintf(tmp,"%s_%s%d_%s_",((CMolecule*)g_oaMolecules[g_iFixMol])->m_sName,((CAtom*)g_oaAtoms[g_iFixRealAtomType[0]])->m_sName,g_iFixAtom[0]+1,((CMolecule*)g_oaMolecules[m_iShowMol])->m_sName);
1868
 
                        else sprintf(tmp,"%s_%s%d_",((CMolecule*)g_oaMolecules[g_iFixMol])->m_sName,((CAtom*)g_oaAtoms[g_iFixRealAtomType[0]])->m_sName,g_iFixAtom[0]+1);
1869
 
        strcat(tmp,m_sShortName);
1870
 
 
1871
 
        try { m_sName = new char[strlen(tmp)+1]; } catch(...) { m_sName = NULL; }
1872
 
        if (m_sName == NULL) NewException((double)(strlen(tmp)+1)*sizeof(char),__FILE__,__LINE__,__PRETTY_FUNCTION__);
1873
 
        
1874
 
        strcpy(m_sName,tmp);
1875
 
        BTOUT;
1876
 
}
1877
 
 
1878
 
 
1879
 
void CRDF::Parse()
1880
 
{
1881
 
        BTIN;
1882
 
        char buf[256];
1883
 
        int ti;
1884
 
        CAtomGroup *ag;
1885
 
 
1886
 
        try { m_pRDF = new CDF(); } catch(...) { m_pRDF = NULL; }
1887
 
        if (m_pRDF == NULL) NewException((double)sizeof(CDF),__FILE__,__LINE__,__PRETTY_FUNCTION__);
1888
 
        
1889
 
        m_iShowAtomGes = 0;
1890
 
        m_iRefAtomGes = 0;
1891
 
        m_iCombinations = 0;
1892
 
        mprintf(WHITE,"\n>>> Radial Distribution Function >>>\n\n");
1893
 
/*      if (m_bSelf)
1894
 
        {
1895
 
                m_iRefOrSec[0] = 0;
1896
 
                m_iRefOrSec[1] = 0;
1897
 
        } else
1898
 
        {
1899
 
                m_iRefOrSec[0] = 0;
1900
 
                m_iRefOrSec[1] = 1;
1901
 
        }*/
1902
 
        if (m_iShowMol != -1)
1903
 
                m_iRefOrSec[0] = AskRangeInteger("    Take reference atom(s) from RM %s (0) or from OM %s (1)? [0] ",0,1,0,((CMolecule*)g_oaMolecules[g_iFixMol])->m_sName,((CMolecule*)g_oaMolecules[m_iShowMol])->m_sName);
1904
 
                        else m_iRefOrSec[0] = 0; // Kein OM: Nimm alles aus RM
1905
 
        if (m_iShowMol != -1)
1906
 
                m_iRefOrSec[1] = AskRangeInteger("    Take observed atom(s) from RM %s (0) or from OM %s (1)? [1] ",0,1,1,((CMolecule*)g_oaMolecules[g_iFixMol])->m_sName,((CMolecule*)g_oaMolecules[m_iShowMol])->m_sName);
1907
 
                        else m_iRefOrSec[1] = 0; // Kein OM: Nimm alles aus RM
1908
 
                
1909
 
_rdfnewset:
1910
 
        mprintf("\n");
1911
 
 
1912
 
        try { ag = new CAtomGroup(); } catch(...) { ag = NULL; }
1913
 
        if (ag == NULL) NewException((double)sizeof(CAtomGroup),__FILE__,__LINE__,__PRETTY_FUNCTION__);
1914
 
        
1915
 
_rdfatom1:
1916
 
        // 1 reales + 2 virtuelle = 3 gesamt
1917
 
        if (((CMolecule*)g_oaMolecules[(m_iRefOrSec[0])?m_iShowMol:g_iFixMol])->m_iAtomGes == 3)
1918
 
        {
1919
 
                mprintf("    %s is only one atom, there is no choice.\n",((CMolecule*)g_oaMolecules[(m_iRefOrSec[0])?m_iShowMol:g_iFixMol])->m_sName);
1920
 
                ag->Reset();
1921
 
                ag->m_pMolecule = (CMolecule*)g_oaMolecules[(m_iRefOrSec[0])?m_iShowMol:g_iFixMol];
1922
 
                ag->AddAtom(0,0,false);
1923
 
                ag->SortAtoms();
1924
 
                ag->BuildName();
1925
 
        } else
1926
 
        {
1927
 
                if (m_iRefOrSec[0])
1928
 
                {
1929
 
                        mprintf("    Which atom(s) to take from OM %s (e.g. \"C1,C3-5,H\", \"*\"=all)? [#2] ",((CMolecule*)g_oaMolecules[m_iShowMol])->m_sName);
1930
 
                        inpprintf("! Which atom(s) to take from OM %s (e.g. \"C1,C3-5,H\", \"*\"=all)? [#2]\n",((CMolecule*)g_oaMolecules[m_iShowMol])->m_sName);
1931
 
                } else
1932
 
                {
1933
 
                        mprintf("    Which atom(s) to take from RM %s (e.g. \"C1,C3-5,H\", \"*\"=all)? [#2] ",((CMolecule*)g_oaMolecules[g_iFixMol])->m_sName);
1934
 
                        inpprintf("! Which atom(s) to take from RM %s (e.g. \"C1,C3-5,H\", \"*\"=all)? [#2]\n",((CMolecule*)g_oaMolecules[g_iFixMol])->m_sName);
1935
 
                }
1936
 
                myget(buf);
1937
 
                if (strlen(buf) == 0)
1938
 
                {
1939
 
                        if (!ag->ParseAtoms((CMolecule*)g_oaMolecules[(m_iRefOrSec[0])?m_iShowMol:g_iFixMol],"#2"))
1940
 
                        {
1941
 
                                eprintf("Weird error.\n");
1942
 
                                goto _rdfatom1;
1943
 
                        }
1944
 
                } else if (!ag->ParseAtoms((CMolecule*)g_oaMolecules[(m_iRefOrSec[0])?m_iShowMol:g_iFixMol],buf))
1945
 
                        goto _rdfatom1;
1946
 
        }
1947
 
        m_oaVectors.Add(ag);
1948
 
        m_iRefAtomGes += ag->m_iAtomGes;
1949
 
        ti = ag->m_iAtomGes;
1950
 
 
1951
 
        try { ag = new CAtomGroup(); } catch(...) { ag = NULL; }
1952
 
        if (ag == NULL) NewException((double)sizeof(CAtomGroup),__FILE__,__LINE__,__PRETTY_FUNCTION__);
1953
 
        
1954
 
_rdfatom2:
1955
 
        if (((CMolecule*)g_oaMolecules[(m_iRefOrSec[1])?m_iShowMol:g_iFixMol])->m_iAtomGes == 3)
1956
 
        {
1957
 
                mprintf("    %s is only one atom, there is no choice.\n",((CMolecule*)g_oaMolecules[(m_iRefOrSec[1])?m_iShowMol:g_iFixMol])->m_sName);
1958
 
                ag->Reset();
1959
 
                ag->m_pMolecule = (CMolecule*)g_oaMolecules[(m_iRefOrSec[1])?m_iShowMol:g_iFixMol];
1960
 
                ag->AddAtom(0,0,false);
1961
 
                ag->SortAtoms();
1962
 
                ag->BuildName();
1963
 
        } else
1964
 
        {
1965
 
                if (m_iRefOrSec[1])
1966
 
                {
1967
 
                        mprintf("    Which atom(s) to take from OM %s (e.g. \"C1,C3-5,H\", \"*\"=all)? [#2] ",((CMolecule*)g_oaMolecules[m_iShowMol])->m_sName);
1968
 
                        inpprintf("! Which atom(s) to take from OM %s (e.g. \"C1,C3-5,H\", \"*\"=all)? [#2]\n",((CMolecule*)g_oaMolecules[m_iShowMol])->m_sName);
1969
 
                } else
1970
 
                {
1971
 
                        mprintf("    Which atom(s) to take from RM %s (e.g. \"C1,C3-5,H\", \"*\"=all)? [#2] ",((CMolecule*)g_oaMolecules[g_iFixMol])->m_sName);
1972
 
                        inpprintf("! Which atom(s) to take from RM %s (e.g. \"C1,C3-5,H\", \"*\"=all)? [#2]\n",((CMolecule*)g_oaMolecules[g_iFixMol])->m_sName);
1973
 
                }
1974
 
                myget(buf);
1975
 
 
1976
 
                try { ag = new CAtomGroup(); } catch(...) { ag = NULL; }
1977
 
                if (ag == NULL) NewException((double)sizeof(CAtomGroup),__FILE__,__LINE__,__PRETTY_FUNCTION__);
1978
 
 
1979
 
                if (strlen(buf) == 0)
1980
 
                {
1981
 
                        if (!ag->ParseAtoms((CMolecule*)g_oaMolecules[(m_iRefOrSec[1])?m_iShowMol:g_iFixMol],"#2"))
1982
 
                        {
1983
 
                                eprintf("Weird error.\n");
1984
 
                                goto _rdfatom2;
1985
 
                        }
1986
 
                } else if (!ag->ParseAtoms((CMolecule*)g_oaMolecules[(m_iRefOrSec[1])?m_iShowMol:g_iFixMol],buf))
1987
 
                        goto _rdfatom2;
1988
 
        }
1989
 
        m_oaVectors.Add(ag);
1990
 
        m_iShowAtomGes += ag->m_iAtomGes;
1991
 
        m_iCombinations += ti * ag->m_iAtomGes;
1992
 
 
1993
 
        if (g_bAdvanced2)
1994
 
                if (AskYesNo("    Add another set of atoms to this (!) RDF (y/n)? [no] ",false))
1995
 
                        goto _rdfnewset;
1996
 
 
1997
 
        mprintf("    This yields in %d combinations.\n\n",m_iCombinations);
1998
 
 
1999
 
        ParseDeriv();
2000
 
 
2001
 
        switch(m_iDeriv)
2002
 
        {
2003
 
                case 0:
2004
 
                        m_fMinDist = AskFloat("    Enter the minimal radius of this RDF in pm: [0] ",0.0f);
2005
 
                        m_fMaxDist = AskFloat("    Enter the maximal radius of this RDF in pm: [%d.0] ",(float)HalfBox(),HalfBox());
2006
 
                        break;
2007
 
                case 1:
2008
 
                        if (m_bDerivAbs)
2009
 
                                m_fMinDist = AskFloat("    Enter the minimal value of this d1-RDF in pm/ps: [0] ",0.0f);
2010
 
                                        else m_fMinDist = AskFloat("    Enter the minimal value of this d1-RDF in pm/ps: [-10.0] ",-10.0f);
2011
 
                        m_fMaxDist = AskFloat("    Enter the maximal value of this d1-RDF in pm/ps: [10.0] ",10.0f);
2012
 
                        break;
2013
 
                case 2:
2014
 
                        if (m_bDerivAbs)
2015
 
                                m_fMinDist = AskFloat("    Enter the minimal value of this d2-RDF in pm/ps^2: [0] ",0.0f);
2016
 
                                        else m_fMinDist = AskFloat("    Enter the minimal value of this d2-RDF in pm/ps^2: [-10.0] ",-10.0f);
2017
 
                        m_fMaxDist = AskFloat("    Enter the maximal value of this d2-RDF in pm/ps^2: [10.0] ",10.0f);
2018
 
                        break;
2019
 
        }
2020
 
        m_bAdaptive = false/*AskYesNo("    Enter binning resolution (n) or use adaptive binnig (y)? [no] ",false)*/;
2021
 
        if (!m_bAdaptive)
2022
 
                m_iResolution = AskUnsignedInteger("    Enter the resolution (bin count) for this RDF: [300] ",/*(int)((m_fMaxDist-m_fMinDist)/10.0f),(int)((m_fMaxDist-m_fMinDist)/10.0f)*/300);
2023
 
                        else m_iResolution = 65536;
2024
 
 
2025
 
        if (g_bAdvanced2)
2026
 
                m_iHistogramRes = AskUnsignedInteger("    Please enter histogram resolution (0=no histogram): [5000] ",5000);
2027
 
                        else m_iHistogramRes = 0;
2028
 
 
2029
 
        if (m_iDeriv == 0)
2030
 
        {
2031
 
                if (m_iShowMol != -1)
2032
 
                        m_bRadialCorrect = AskYesNo("    Correct radial distribution for this RDF (y/n)? [yes] ",true);
2033
 
                                else m_bRadialCorrect = AskYesNo("    Correct radial distribution for this RDF (y/n)? [no] ",false);
2034
 
        } else m_bRadialCorrect = false;
2035
 
 
2036
 
        if (g_bAdvanced2 && m_bRadialCorrect)
2037
 
                m_bProbDens = AskYesNo("    Compute occurence in nm^(-3) (y) or rel. to uniform density (n)? [no] ",false);
2038
 
                        else m_bProbDens = false;
2039
 
 
2040
 
        if (g_bBetaFeatures)
2041
 
                m_bCalcSD = AskYesNo("    Calculate standard deviation for this RDF (y/n)? [no] ",false);
2042
 
                        else m_bCalcSD = false;
2043
 
 
2044
 
        if (m_bCalcSD)
2045
 
        {
2046
 
                m_iSDBlocks = AskUnsignedInteger("    How many different block lenghts to use? [100] ",100);
2047
 
                m_iSDBlockMin = AskUnsignedInteger("    Enter minimal block length in time steps: [1] ",1);
2048
 
                if (g_iTrajSteps != -1)
2049
 
                        m_iSDBlockMax = AskUnsignedInteger("    Enter maximal block length in time steps: [%d] ",g_iTrajSteps/10,g_iTrajSteps/10);
2050
 
                                else m_iSDBlockMax = AskUnsignedInteger("    Enter maximal block length in time steps: [1000] ",1000);
2051
 
                m_bSDVerbose = AskYesNo("    Write out correlation length extrapolation fit data for each bin (y/n)? [no] ",false);
2052
 
                m_fSDTimesSigma = AskFloat("    Use which factor of sigma for confidence range? [3.0] ",3.0);
2053
 
                mprintf("\n    %.2f sigma leads to a confidence level of %.5f%c.\n",m_fSDTimesSigma,2.0*NormalDistIntegral(m_fSDTimesSigma)-1.0,'%');
2054
 
        }
2055
 
 
2056
 
        BuildName();
2057
 
        mprintf(WHITE,"\n<<< End of Radial Distribution Function <<<\n\n");
2058
 
        BTOUT;
2059
 
}
2060
 
 
2061
 
 
2062
 
void CDensDF::Parse()
2063
 
{
2064
 
        BTIN;
2065
 
        char buf[256];
2066
 
        int z;
2067
 
        CMolecule *m;
2068
 
 
2069
 
        try { m_pDensDF = new CDF(); } catch(...) { m_pDensDF = NULL; }
2070
 
        if (m_pDensDF == NULL) NewException((double)sizeof(CDF),__FILE__,__LINE__,__PRETTY_FUNCTION__);
2071
 
        
2072
 
        mprintf(WHITE,"\n>>> Density Distribution Function >>>\n\n");
2073
 
 
2074
 
        m_bDensityMass = AskYesNo("    Observe mass density (y) or particle density (n)? [yes] ",true);
2075
 
 
2076
 
        mprintf("\n    Choose a reference atom around which the density will be analyzed.\n\n");
2077
 
 
2078
 
        // 1 reales + 2 virtuelle = 3 gesamt
2079
 
        if (((CMolecule*)g_oaMolecules[m_iShowMol])->m_iAtomGesNoVirt == 1)
2080
 
        {
2081
 
                mprintf("    %s is only one atom, there is no choice.\n",((CMolecule*)g_oaMolecules[m_iShowMol])->m_sName);
2082
 
                if (!ParseAtom("#2",m_iShowMol,m_iCenterAtomType,m_iCenterAtomRealType,m_iCenterAtom))
2083
 
                {
2084
 
                        eprintf("Weird error.\n");
2085
 
                        abort();
2086
 
                }
2087
 
        } else
2088
 
        {
2089
 
_densatom1:
2090
 
                mprintf("    Which atom to take from OM %s (e.g. C1)? [#2] ",((CMolecule*)g_oaMolecules[m_iShowMol])->m_sName);
2091
 
                inpprintf("! Which atom to take from OM %s (e.g. C1)? [#2]\n",((CMolecule*)g_oaMolecules[m_iShowMol])->m_sName);
2092
 
                myget(buf);
2093
 
                if (strlen(buf) == 0)
2094
 
                {
2095
 
                        if (!ParseAtom("#2",m_iShowMol,m_iCenterAtomType,m_iCenterAtomRealType,m_iCenterAtom))
2096
 
                        {
2097
 
                                eprintf("Weird error.\n");
2098
 
                                abort();
2099
 
                        }
2100
 
                } else if (!ParseAtom(buf,m_iShowMol,m_iCenterAtomType,m_iCenterAtomRealType,m_iCenterAtom))
2101
 
                        goto _densatom1;
2102
 
        }
2103
 
 
2104
 
        try { m_pDensityMolSelect = new bool[g_oaMolecules.GetSize()]; } catch(...) { m_pDensityMolSelect = NULL; }
2105
 
        if (m_pDensityMolSelect == NULL) NewException((double)g_oaMolecules.GetSize()*sizeof(bool),__FILE__,__LINE__,__PRETTY_FUNCTION__);
2106
 
 
2107
 
        try { m_pDensityMolAG = new CAtomGroup*[g_oaMolecules.GetSize()]; } catch(...) { m_pDensityMolAG = NULL; }
2108
 
        if (m_pDensityMolAG == NULL) NewException((double)g_oaMolecules.GetSize()*sizeof(CAtomGroup*),__FILE__,__LINE__,__PRETTY_FUNCTION__);
2109
 
        
2110
 
        mprintf("\n    Please choose the atoms to observe:\n\n");
2111
 
 
2112
 
        for (z=0;z<g_oaMolecules.GetSize();z++)
2113
 
        {
2114
 
                m = (CMolecule*)g_oaMolecules[z];
2115
 
                m_pDensityMolSelect[z] = AskYesNo("    Consider contributions from %s (y/n)? [%s] ",!m->m_bPseudo,((CMolecule*)g_oaMolecules[z])->m_sName,m->m_bPseudo?"no":"yes");
2116
 
                if (m_pDensityMolSelect[z])
2117
 
                {
2118
 
                        try { m_pDensityMolAG[z] = new CAtomGroup(); } catch(...) { m_pDensityMolAG[z] = NULL; }
2119
 
                        if (m_pDensityMolAG[z] == NULL) NewException((double)sizeof(CAtomGroup),__FILE__,__LINE__,__PRETTY_FUNCTION__);
2120
 
_densatom2:
2121
 
                        AskString("      Which atoms from %s to observe (e.g. C1-3,C6,N)? [all] ",buf,"",m->m_sName);
2122
 
                        if (strlen(buf) == 0)
2123
 
                        {
2124
 
                                m_pDensityMolAG[z]->AddAllAtoms(m,false);
2125
 
                        } else if (!m_pDensityMolAG[z]->ParseAtoms(m,buf))
2126
 
                                goto _densatom2;
2127
 
                }
2128
 
        }
2129
 
 
2130
 
        mprintf("\n");
2131
 
 
2132
 
        m_fMinDist = AskFloat("    Enter the minimal radius of this Density DF in pm: [0] ",0.0f);
2133
 
        m_fMaxDist = AskFloat("    Enter the maximal radius of this Density DF in pm: [%d.0] ",(float)HalfBox(),HalfBox());
2134
 
 
2135
 
        m_iResolution = AskUnsignedInteger("    Enter the resolution (bin count) for this Density DF: [300] ",300);
2136
 
 
2137
 
        if (g_bAdvanced2)
2138
 
                m_iHistogramRes = AskUnsignedInteger("    Please enter histogram resolution (0=no histogram): [5000] ",5000);
2139
 
                        else m_iHistogramRes = 0;
2140
 
 
2141
 
        BuildName();
2142
 
        mprintf(WHITE,"\n<<< End of Density Distribution Function <<<\n\n");
2143
 
        BTOUT;
2144
 
}
2145
 
 
2146
 
 
2147
 
void CRDF::ParseCondition(int rm, CNbSearch *n, bool nbana)
2148
 
{
2149
 
        BTIN;
2150
 
        char buf[256];
2151
 
        int ti;
2152
 
        CAtomGroup *ag;
2153
 
 
2154
 
        try { m_pRDF = new CDF(); } catch(...) { m_pRDF = NULL; }
2155
 
        if (m_pRDF == NULL) NewException((double)sizeof(CDF),__FILE__,__LINE__,__PRETTY_FUNCTION__);
2156
 
        
2157
 
        m_iShowAtomGes = 0;
2158
 
        m_iRefAtomGes = 0;
2159
 
        m_iCombinations = 0;
2160
 
        m_iRefOrSec[0] = 0;
2161
 
        m_iRefOrSec[1] = 1;
2162
 
        mprintf(WHITE,"\n>>> Distance Condition >>>\n");
2163
 
        
2164
 
_rdfnewset:
2165
 
        mprintf("\n");
2166
 
 
2167
 
        try { ag = new CAtomGroup(); } catch(...) { ag = NULL; }
2168
 
        if (ag == NULL) NewException((double)sizeof(CAtomGroup),__FILE__,__LINE__,__PRETTY_FUNCTION__);
2169
 
 
2170
 
_rdfatom1:
2171
 
        if (((CMolecule*)g_oaMolecules[rm])->m_iAtomGes == 3)
2172
 
        {
2173
 
                mprintf("    %s is only one atom, there is no choice.\n",((CMolecule*)g_oaMolecules[rm])->m_sName);
2174
 
                ag->Reset();
2175
 
                ag->m_pMolecule = (CMolecule*)g_oaMolecules[rm];
2176
 
                ag->AddAtom(0,0,false);
2177
 
                ag->SortAtoms();
2178
 
                ag->BuildName();
2179
 
        } else
2180
 
        {
2181
 
                mprintf("    Which atom(s) to take from RM %s (e.g. \"C1,C3-5,H\", \"*\"=all)? [#2] ",((CMolecule*)g_oaMolecules[rm])->m_sName);
2182
 
                inpprintf("! Which atom(s) to take from RM %s (e.g. \"C1,C3-5,H\", \"*\"=all)? [#2]\n",((CMolecule*)g_oaMolecules[rm])->m_sName);
2183
 
                myget(buf);
2184
 
                if (strlen(buf) == 0)
2185
 
                {
2186
 
                        if (!ag->ParseAtoms((CMolecule*)g_oaMolecules[rm],"#2"))
2187
 
                        {
2188
 
                                eprintf("Weird error.\n");
2189
 
                                goto _rdfatom1;
2190
 
                        }
2191
 
                } else if (!ag->ParseAtoms((CMolecule*)g_oaMolecules[rm],buf))
2192
 
                        goto _rdfatom1;
2193
 
        }
2194
 
        m_oaVectors.Add(ag);
2195
 
        m_iRefAtomGes += ag->m_iAtomGes;
2196
 
        ti = ag->m_iAtomGes;
2197
 
 
2198
 
        try { ag = new CAtomGroup(); } catch(...) { ag = NULL; }
2199
 
        if (ag == NULL) NewException((double)sizeof(CAtomGroup),__FILE__,__LINE__,__PRETTY_FUNCTION__);
2200
 
 
2201
 
_rdfatom2:
2202
 
        if (((CMolecule*)g_oaMolecules[m_iShowMol])->m_iAtomGes == 3)
2203
 
        {
2204
 
                mprintf("    %s is only one atom, there is no choice.\n",((CMolecule*)g_oaMolecules[m_iShowMol])->m_sName);
2205
 
                ag->Reset();
2206
 
                ag->m_pMolecule = (CMolecule*)g_oaMolecules[m_iShowMol];
2207
 
                ag->AddAtom(0,0,false);
2208
 
                ag->SortAtoms();
2209
 
                ag->BuildName();
2210
 
        } else
2211
 
        {
2212
 
                mprintf("    Which atom(s) to take from OM %s (e.g. \"C1,C3-5,H\", \"*\"=all)? [#2] ",((CMolecule*)g_oaMolecules[m_iShowMol])->m_sName);
2213
 
                inpprintf("! Which atom(s) to take from OM %s (e.g. \"C1,C3-5,H\", \"*\"=all)? [#2]\n",((CMolecule*)g_oaMolecules[m_iShowMol])->m_sName);
2214
 
                myget(buf);
2215
 
 
2216
 
                try { ag = new CAtomGroup(); } catch(...) { ag = NULL; }
2217
 
                if (ag == NULL) NewException((double)sizeof(CAtomGroup),__FILE__,__LINE__,__PRETTY_FUNCTION__);
2218
 
 
2219
 
                if (strlen(buf) == 0)
2220
 
                {
2221
 
                        if (!ag->ParseAtoms((CMolecule*)g_oaMolecules[m_iShowMol],"#2"))
2222
 
                        {
2223
 
                                eprintf("Weird error.\n");
2224
 
                                goto _rdfatom2;
2225
 
                        }
2226
 
                } else if (!ag->ParseAtoms((CMolecule*)g_oaMolecules[m_iShowMol],buf))
2227
 
                        goto _rdfatom2;
2228
 
        }
2229
 
        m_oaVectors.Add(ag);
2230
 
        m_iShowAtomGes += ag->m_iAtomGes;
2231
 
        m_iCombinations += ti * ag->m_iAtomGes;
2232
 
 
2233
 
        if (AskYesNo("    Enter another set of atoms for this condition (y/n)? [no] ",false))
2234
 
                goto _rdfnewset;
2235
 
 
2236
 
        if (!nbana)
2237
 
        {
2238
 
                if (AskUnsignedInteger("\n    Enter min./max. distance (0) or min./max. nearest neighbor count (1)? [0] ",0)==0)
2239
 
                {
2240
 
                        g_bEnvDisableSortNb = true;
2241
 
 
2242
 
                        do {
2243
 
                                m_faMinMaxDist.Add(AskFloat("    Enter the minimal distance in pm: [0] ",0.0f));
2244
 
                                m_faMinMaxDist.Add(AskFloat("    Enter the maximal distance in pm: [400] ",400.0f));
2245
 
                        } while (AskYesNo("    Enter another distance interval (y/n)? [no] ",false));
2246
 
                        n->m_iNbCountMin = -1;
2247
 
                        n->m_iNbCountMax = -1;
2248
 
                } else
2249
 
                {
2250
 
                        n->m_iNbCountMin = AskRangeInteger("    Use next neighbors from the n-th on? [1] ",0,((CMolecule*)g_oaMolecules[m_iShowMol])->m_laSingleMolIndex.GetSize(),1)-1;
2251
 
                        n->m_iNbCountMax = AskRangeInteger("    Use next neighbors up to the n-th? [%d] ",n->m_iNbCountMin+1,((CMolecule*)g_oaMolecules[m_iShowMol])->m_laSingleMolIndex.GetSize(),n->m_iNbCountMin+1,n->m_iNbCountMin+1)-1;
2252
 
//                      m_faMinMaxDist.Add(0);
2253
 
//                      m_faMinMaxDist.Add(9E20f);
2254
 
                }
2255
 
        } else
2256
 
        {
2257
 
                m_faMinMaxDist.Add(0);
2258
 
                m_faMinMaxDist.Add(1.0e30f);
2259
 
                n->m_iNbCountMin = -2;
2260
 
                n->m_iNbCountMax = -2;
2261
 
        }
2262
 
        mprintf(WHITE,"\n<<< End of Distance Condition <<<\n\n");
2263
 
        BTOUT;
2264
 
}
2265
 
 
2266
 
 
2267
 
void CRDF::ParseConditionGrid(int rm, CNbSearch *n, int gridmode)
2268
 
{
2269
 
        BTIN;
2270
 
        char buf[256];
2271
 
        int ti;
2272
 
        CAtomGroup *ag;
2273
 
 
2274
 
        try { m_pRDF = new CDF(); } catch(...) { m_pRDF = NULL; }
2275
 
        if (m_pRDF == NULL) NewException((double)sizeof(CDF),__FILE__,__LINE__,__PRETTY_FUNCTION__);
2276
 
        
2277
 
        m_iShowAtomGes = 0;
2278
 
        m_iRefAtomGes = 0;
2279
 
        m_iCombinations = 0;
2280
 
        m_iRefOrSec[0] = 0;
2281
 
        m_iRefOrSec[1] = 1;
2282
 
        mprintf(WHITE,"\n>>> Distance Condition >>>\n");
2283
 
 
2284
 
_rdfnewset:
2285
 
        mprintf("\n");
2286
 
 
2287
 
        try { ag = new CAtomGroup(); } catch(...) { ag = NULL; }
2288
 
        if (ag == NULL) NewException((double)sizeof(CAtomGroup),__FILE__,__LINE__,__PRETTY_FUNCTION__);
2289
 
 
2290
 
_rdfatom1:
2291
 
        if (((CMolecule*)g_oaMolecules[rm])->m_iAtomGes == 3)
2292
 
        {
2293
 
                mprintf("    %s is only one atom, there is no choice.\n",((CMolecule*)g_oaMolecules[rm])->m_sName);
2294
 
                ag->Reset();
2295
 
                ag->m_pMolecule = (CMolecule*)g_oaMolecules[rm];
2296
 
                ag->AddAtom(0,0,false);
2297
 
                ag->SortAtoms();
2298
 
                ag->BuildName();
2299
 
        } else
2300
 
        {
2301
 
                mprintf("    Which atom(s) to take from RM %s (e.g. \"C1,C3-5,H\", \"*\"=all)? [#2] ",((CMolecule*)g_oaMolecules[rm])->m_sName);
2302
 
                inpprintf("! Which atom(s) to take from RM %s (e.g. \"C1,C3-5,H\", \"*\"=all)? [#2]\n",((CMolecule*)g_oaMolecules[rm])->m_sName);
2303
 
                myget(buf);
2304
 
                if (strlen(buf) == 0)
2305
 
                {
2306
 
                        if (!ag->ParseAtoms((CMolecule*)g_oaMolecules[rm],"#2"))
2307
 
                        {
2308
 
                                eprintf("Weird error.\n");
2309
 
                                goto _rdfatom1;
2310
 
                        }
2311
 
                } else if (!ag->ParseAtoms((CMolecule*)g_oaMolecules[rm],buf))
2312
 
                        goto _rdfatom1;
2313
 
        }
2314
 
        m_oaVectors.Add(ag);
2315
 
        m_iRefAtomGes += ag->m_iAtomGes;
2316
 
        ti = ag->m_iAtomGes;
2317
 
 
2318
 
        try { ag = new CAtomGroup(); } catch(...) { ag = NULL; }
2319
 
        if (ag == NULL) NewException((double)sizeof(CAtomGroup),__FILE__,__LINE__,__PRETTY_FUNCTION__);
2320
 
 
2321
 
_rdfatom2:
2322
 
        if (((CMolecule*)g_oaMolecules[m_iShowMol])->m_iAtomGes == 3)
2323
 
        {
2324
 
                mprintf("    %s is only one atom, there is no choice.\n",((CMolecule*)g_oaMolecules[m_iShowMol])->m_sName);
2325
 
                ag->Reset();
2326
 
                ag->m_pMolecule = (CMolecule*)g_oaMolecules[m_iShowMol];
2327
 
                ag->AddAtom(0,0,false);
2328
 
                ag->SortAtoms();
2329
 
                ag->BuildName();
2330
 
        } else
2331
 
        {
2332
 
                mprintf("    Which atom(s) to take from OM %s (e.g. \"C1,C3-5,H\", \"*\"=all)? [#2] ",((CMolecule*)g_oaMolecules[m_iShowMol])->m_sName);
2333
 
                inpprintf("! Which atom(s) to take from OM %s (e.g. \"C1,C3-5,H\", \"*\"=all)? [#2]\n",((CMolecule*)g_oaMolecules[m_iShowMol])->m_sName);
2334
 
                myget(buf);
2335
 
 
2336
 
                try { ag = new CAtomGroup(); } catch(...) { ag = NULL; }
2337
 
                if (ag == NULL) NewException((double)sizeof(CAtomGroup),__FILE__,__LINE__,__PRETTY_FUNCTION__);
2338
 
 
2339
 
                if (strlen(buf) == 0)
2340
 
                {
2341
 
                        if (!ag->ParseAtoms((CMolecule*)g_oaMolecules[m_iShowMol],"#2"))
2342
 
                        {
2343
 
                                eprintf("Weird error.\n");
2344
 
                                goto _rdfatom2;
2345
 
                        }
2346
 
                } else if (!ag->ParseAtoms((CMolecule*)g_oaMolecules[m_iShowMol],buf))
2347
 
                        goto _rdfatom2;
2348
 
        }
2349
 
        m_oaVectors.Add(ag);
2350
 
        m_iShowAtomGes += ag->m_iAtomGes;
2351
 
        m_iCombinations += ti * ag->m_iAtomGes;
2352
 
 
2353
 
        if (AskYesNo("    Enter another set of atoms (y/n)? [no] ",false))
2354
 
                goto _rdfnewset;
2355
 
 
2356
 
        if (gridmode == 6)
2357
 
        {
2358
 
                if (AskUnsignedInteger("\n    Enter min./max. distance (0) or min./max. nearest neighbor count (1)? [0] ",0)==0)
2359
 
                {
2360
 
                        m_faMinMaxDist.Add(AskFloat("    Enter the minimal distance in pm: [0] ",0.0f));
2361
 
                        m_faMinMaxDist.Add(AskFloat("    Enter the maximal distance in pm: [400] ",400.0f));
2362
 
                        n->m_iNbCountMin = -1;
2363
 
                        n->m_iNbCountMax = -1;
2364
 
                } else
2365
 
                {
2366
 
                        n->m_iNbCountMin = AskRangeInteger("    Use next neighbors from the n-th on? [1] ",0,((CMolecule*)g_oaMolecules[m_iShowMol])->m_laSingleMolIndex.GetSize(),1)-1;
2367
 
                        n->m_iNbCountMax = AskRangeInteger("    Use next neighbors up to the n-th? [%d] ",n->m_iNbCountMin+1,((CMolecule*)g_oaMolecules[m_iShowMol])->m_laSingleMolIndex.GetSize(),n->m_iNbCountMin+1,n->m_iNbCountMin+1)-1;
2368
 
//                      m_faMinMaxDist.Add(0);
2369
 
//                      m_faMinMaxDist.Add(9E20f);
2370
 
                }
2371
 
        } else if ((gridmode == 4) || (gridmode == 5))
2372
 
        {
2373
 
                n->m_iNbCountMin = 0;
2374
 
                n->m_iNbCountMax = 0;
2375
 
//              m_faMinMaxDist.Add(0);
2376
 
//              m_faMinMaxDist.Add(9E20f);
2377
 
        } else if (gridmode == 2)
2378
 
        {
2379
 
                m_faMinMaxDist.Add(AskFloat("    Enter the minimal distance in pm: [0] ",0.0f));
2380
 
                m_faMinMaxDist.Add(AskFloat("    Enter the maximal distance in pm: [400] ",400.0f));
2381
 
                n->m_iNbCountMin = -1;
2382
 
                n->m_iNbCountMax = -1;
2383
 
        } else 
2384
 
        {
2385
 
                m_faMinMaxDist.Add(0.0f);
2386
 
                m_faMinMaxDist.Add(400.0f);
2387
 
                n->m_iNbCountMin = -1;
2388
 
                n->m_iNbCountMax = -1;
2389
 
        }
2390
 
        mprintf(WHITE,"\n<<< End of Distance Condition <<<\n\n");
2391
 
        BTOUT;
2392
 
}
2393
 
 
2394
 
 
2395
 
void CRDF::ParseCondition_OnlyValues(CNbSearch *n)
2396
 
{
2397
 
        BTIN;
2398
 
        int z;
2399
 
 
2400
 
        mprintf("    Distance condition between ");
2401
 
        for (z=0;z<m_oaVectors.GetSize()/2;z++)
2402
 
        {
2403
 
                mprintf("%s and %s",((CAtomGroup*)m_oaVectors[z*2])->m_sName,((CAtomGroup*)m_oaVectors[z*2+1])->m_sName);
2404
 
                if (z < (m_oaVectors.GetSize()/2)-1)
2405
 
                        mprintf(", ");
2406
 
        }
2407
 
        mprintf("\n");
2408
 
        if (n->m_iNbCountMin == -1)
2409
 
        {
2410
 
                for (z=0;z<m_faMinMaxDist.GetSize()/2;z++)
2411
 
                {
2412
 
                        mprintf("    Interval %d:\n",z+1,m_faMinMaxDist.GetSize()/2);
2413
 
                        m_faMinMaxDist[z*2] = AskFloat("      Enter the minimal distance in pm: [0] ",0.0f);
2414
 
                        m_faMinMaxDist[z*2+1] = AskFloat("      Enter the maximal distance in pm: [400] ",400.0f);
2415
 
                }
2416
 
        } else
2417
 
        {
2418
 
                n->m_iNbCountMin = AskRangeInteger("    Use next neighbors from the n-th on? [1] ",0,((CMolecule*)g_oaMolecules[m_iShowMol])->m_laSingleMolIndex.GetSize(),1)-1;
2419
 
                n->m_iNbCountMax = AskRangeInteger("    Use next neighbors up to the n-th? [%d] ",n->m_iNbCountMin+1,((CMolecule*)g_oaMolecules[m_iShowMol])->m_laSingleMolIndex.GetSize(),n->m_iNbCountMin+1,n->m_iNbCountMin+1)-1;
2420
 
        }
2421
 
 
2422
 
        BTOUT;
2423
 
}
2424
 
 
2425
 
 
2426
 
void CVHDF::Parse()
2427
 
{
2428
 
        BTIN;
2429
 
        char buf[256];
2430
 
        int ti;
2431
 
        CAtomGroup *ag;
2432
 
 
2433
 
        try { m_pVHDF = new C2DF(); } catch(...) { m_pVHDF = NULL; }
2434
 
        if (m_pVHDF == NULL) NewException((double)sizeof(C2DF),__FILE__,__LINE__,__PRETTY_FUNCTION__);
2435
 
        
2436
 
        m_iShowAtomGes = 0;
2437
 
        m_iRefAtomGes = 0;
2438
 
        m_iCombinations = 0;
2439
 
        mprintf(WHITE,"\n>>> Van Hove Correlation Function >>>\n\n");
2440
 
        if (m_iShowMol != -1)
2441
 
        {
2442
 
                m_iRefOrSec[0] = AskRangeInteger("    Take (fixed) reference atom(s) from RM %s (0) or from OM %s (1)? [0] ",0,1,0,((CMolecule*)g_oaMolecules[g_iFixMol])->m_sName,((CMolecule*)g_oaMolecules[m_iShowMol])->m_sName);
2443
 
                m_iRefOrSec[1] = AskRangeInteger("    Take (moving) observed atom(s) from RM %s (0) or from OM %s (1)? [1] ",0,1,1,((CMolecule*)g_oaMolecules[g_iFixMol])->m_sName,((CMolecule*)g_oaMolecules[m_iShowMol])->m_sName);
2444
 
        } else // Kein OM: Nimm alles aus RM
2445
 
        {
2446
 
                m_iRefOrSec[0] = 0;
2447
 
                m_iRefOrSec[1] = 0;
2448
 
        }
2449
 
_rdfnewset:
2450
 
        mprintf("\n");
2451
 
 
2452
 
        try { ag = new CAtomGroup(); } catch(...) { ag = NULL; }
2453
 
        if (ag == NULL) NewException((double)sizeof(CAtomGroup),__FILE__,__LINE__,__PRETTY_FUNCTION__);
2454
 
 
2455
 
_rdfatom1:
2456
 
        if (m_iRefOrSec[0])
2457
 
        {
2458
 
                mprintf("    Which (fixed) reference atom(s) to take from OM %s (e.g. \"C1,C3-5,H\", \"*\"=all)? [#2] ",((CMolecule*)g_oaMolecules[m_iShowMol])->m_sName);
2459
 
                inpprintf("! Which (fixed) reference atom(s) to take from OM %s (e.g. \"C1,C3-5,H\", \"*\"=all)? [#2]\n",((CMolecule*)g_oaMolecules[m_iShowMol])->m_sName);
2460
 
        } else
2461
 
        {
2462
 
                mprintf("    Which (fixed) reference atom(s) to take from RM %s (e.g. \"C1,C3-5,H\", \"*\"=all)? [#2] ",((CMolecule*)g_oaMolecules[g_iFixMol])->m_sName);
2463
 
                inpprintf("! Which (fixed) reference atom(s) to take from RM %s (e.g. \"C1,C3-5,H\", \"*\"=all)? [#2]\n",((CMolecule*)g_oaMolecules[g_iFixMol])->m_sName);
2464
 
        }
2465
 
        myget(buf);
2466
 
        if (strlen(buf) == 0)
2467
 
        {
2468
 
                if (!ag->ParseAtoms((CMolecule*)g_oaMolecules[(m_iRefOrSec[0])?m_iShowMol:g_iFixMol],"#2"))
2469
 
                        goto _rdfatom1;
2470
 
        } else if (!ag->ParseAtoms((CMolecule*)g_oaMolecules[(m_iRefOrSec[0])?m_iShowMol:g_iFixMol],buf))
2471
 
                goto _rdfatom1;
2472
 
        m_oaVectors.Add(ag);
2473
 
        m_iRefAtomGes += ag->m_iAtomGes;
2474
 
        ti = ag->m_iAtomGes;
2475
 
 
2476
 
        try { ag = new CAtomGroup(); } catch(...) { ag = NULL; }
2477
 
        if (ag == NULL) NewException((double)sizeof(CAtomGroup),__FILE__,__LINE__,__PRETTY_FUNCTION__);
2478
 
 
2479
 
_rdfatom2:
2480
 
        if (m_iRefOrSec[1])
2481
 
        {
2482
 
                mprintf("    Which (moving) observed atom(s) to take from OM %s (e.g. \"C1,C3-5,H\", \"*\"=all)? [#2] ",((CMolecule*)g_oaMolecules[m_iShowMol])->m_sName);
2483
 
                inpprintf("! Which (moving) observed atom(s) to take from OM %s (e.g. \"C1,C3-5,H\", \"*\"=all)? [#2]\n",((CMolecule*)g_oaMolecules[m_iShowMol])->m_sName);
2484
 
        } else
2485
 
        {
2486
 
                mprintf("    Which (moving) observed atom(s) to take from RM %s (e.g. \"C1,C3-5,H\", \"*\"=all)? [#2] ",((CMolecule*)g_oaMolecules[g_iFixMol])->m_sName);
2487
 
                inpprintf("! Which (moving) observed atom(s) to take from RM %s (e.g. \"C1,C3-5,H\", \"*\"=all)? [#2]\n",((CMolecule*)g_oaMolecules[g_iFixMol])->m_sName);
2488
 
        }
2489
 
        myget(buf);
2490
 
 
2491
 
        try { ag = new CAtomGroup(); } catch(...) { ag = NULL; }
2492
 
        if (ag == NULL) NewException((double)sizeof(CAtomGroup),__FILE__,__LINE__,__PRETTY_FUNCTION__);
2493
 
 
2494
 
        if (strlen(buf) == 0)
2495
 
        {
2496
 
                if (!ag->ParseAtoms((CMolecule*)g_oaMolecules[(m_iRefOrSec[1])?m_iShowMol:g_iFixMol],"#2"))
2497
 
                        goto _rdfatom2;
2498
 
        } else if (!ag->ParseAtoms((CMolecule*)g_oaMolecules[(m_iRefOrSec[1])?m_iShowMol:g_iFixMol],buf))
2499
 
                goto _rdfatom2;
2500
 
        m_oaVectors.Add(ag);
2501
 
        m_iShowAtomGes += ag->m_iAtomGes;
2502
 
        m_iCombinations += ti * ag->m_iAtomGes;
2503
 
 
2504
 
        if (g_bAdvanced2)
2505
 
                if (AskYesNo("    Enter another set of atoms (y/n)? [no] ",false))
2506
 
                        goto _rdfnewset;
2507
 
 
2508
 
        m_fMinDist = 0; //AskFloat("    Enter the minimal radius of this VHCF in pm: [0] ",0.0f);
2509
 
        m_fMaxDist = AskFloat("    Enter the radius of this VHCF in pm: [%d.0] ",(float)HalfBox(),HalfBox());
2510
 
        m_iResolution = AskUnsignedInteger("    Enter the radial resolution of this VHCF: [100] ",100);
2511
 
        m_bRadialCorrect = AskYesNo("    Correct radial distribution for this VHCF (y/n)? [%s] ",!m_bSelf,m_bSelf?"no":"yes");
2512
 
 
2513
 
_depth:
2514
 
        if (g_iTrajSteps != -1)
2515
 
                m_iDepth = AskUnsignedInteger("    Enter the temporal resolution (time depth) of this VHCF (in time steps): [%d] ",int(g_iTrajSteps*0.75),int(g_iTrajSteps*0.75));
2516
 
                        else m_iDepth = AskUnsignedInteger("    Enter the temporal resolution (time depth) of this VHCF (in time steps): [5000] ",5000);
2517
 
 
2518
 
        mprintf("\n    This will occupy %s of RAM.\n",FormatBytes((double)m_iDepth*g_iGesVirtAtomCount*3.0*sizeof(float)));
2519
 
        if (m_iDepth*g_iGesVirtAtomCount*3.0*sizeof(float)/1024.0f/1024.0f >= 1000.0f)
2520
 
                if (!AskYesNo("    Make sure that enough free RAM is available. Continue (y/n)? [yes] ",true))
2521
 
                        goto _depth;
2522
 
        mprintf("\n");
2523
 
 
2524
 
_resagain:
2525
 
        m_iStride = AskUnsignedInteger("    Take each n-th time step for the temporal axis? [%d] ",max(1,m_iDepth/100),max(1,m_iDepth/100));
2526
 
 
2527
 
        mprintf("\n    This results in a plot resolution of %d on the temporal axis.\n",m_iDepth/m_iStride);
2528
 
 
2529
 
        if (m_iDepth/m_iStride > 200)
2530
 
        {
2531
 
                mprintf("\n");
2532
 
                if (!AskYesNo("    The resolution seems quite high, the plot will take much time to render. Contiune (y/n)? [yes] ",true))
2533
 
                        goto _resagain;
2534
 
        }
2535
 
 
2536
 
        if (g_bAdvanced2)
2537
 
        {
2538
 
                mprintf("\n");
2539
 
                m_bSwapAxes = AskYesNo("    Put distance on X axis and time on Y axis (y) or swap axes (n)? [yes] ",true);
2540
 
                m_iGraceBunchTime = AskUnsignedInteger("    How many time graphs do you want do draw in the distance grace stack (0=disable)? [10] ",10);
2541
 
                m_iGraceBunchDist = AskUnsignedInteger("    How many distance graphs do you want do draw in the time grace stack (0=disable)? [10] ",10);
2542
 
        } else
2543
 
        {
2544
 
                m_bSwapAxes = true;
2545
 
                m_iGraceBunchTime = 0;
2546
 
                m_iGraceBunchDist = 0;
2547
 
        }
2548
 
 
2549
 
        BuildName();
2550
 
        mprintf(WHITE,"\n<<< End of Van Hove Correlation Function <<<\n\n");
2551
 
        BTOUT;
2552
 
}
2553
 
 
2554
 
 
2555
 
void CADF::Parse()
2556
 
{
2557
 
        BTIN;
2558
 
        char buf[256];
2559
 
        int z, z2, ti;
2560
 
        CAtomGroup *ag;
2561
 
        float tf;
2562
 
 
2563
 
        try { m_pADF = new CDF(); } catch(...) { m_pADF = NULL; }
2564
 
        if (m_pADF == NULL) NewException((double)sizeof(CDF),__FILE__,__LINE__,__PRETTY_FUNCTION__);
2565
 
        
2566
 
        mprintf(WHITE,"\n>>> Angular Distribution Function >>>\n\n");
2567
 
        for (z=0;z<2;z++)
2568
 
        {
2569
 
                m_iVecType[z] = AskRangeInteger("    Should the %d. vector depict position (1), dipole (2), velocity (3) or force (4)? [1] ",1,4,1,z+1) - 1;
2570
 
                if (m_iVecType[z] == 1)
2571
 
                {
2572
 
                        g_bDipole = true;
2573
 
                        ParseDipole();
2574
 
                }
2575
 
        }
2576
 
        z2 = 0;
2577
 
        m_iCombinations = 0;
2578
 
        do {
2579
 
                ti = 1;
2580
 
                if (z2 != 0)
2581
 
                        mprintf("\n    %d. set of vectors\n\n",z2+1);
2582
 
                for (z=0;z<2;z++)
2583
 
                {
2584
 
                        if (m_iVecType[z] == 0) // Position
2585
 
                        {
2586
 
/*                              if (z2 == 0)
2587
 
                                        if ((z == 1) && (m_iVecType[0] == 0) && (m_iVecType[1] == 0))
2588
 
                                                m_bSameFoot = AskYesNo("    Should the base points of the 1st and 2nd vectors always be equal (y/n)? [no] ",false);
2589
 
                                                        else m_bSameFoot = false;*/
2590
 
 
2591
 
                                if (z2 == 0)
2592
 
                                        m_bOrtho[z] = (AskRangeInteger("\n    Should the %d. vector connect 2 points (0) or stand perpendicular to 3 points (1)? [0] ",0,1,0,z+1) != 0);
2593
 
 
2594
 
                                mprintf("\n");
2595
 
                                if (m_bOrtho[z])
2596
 
                                {
2597
 
/*                                      if (m_bSameFoot && (z == 1))
2598
 
                                        {
2599
 
                                                m_iRefOrSec[1][0] = m_iRefOrSec[0][0];
2600
 
                                                m_oaVectors.Add(NULL);
2601
 
                                        } else*/
2602
 
                                        {
2603
 
_ax1:                                   if (z2 == 0)
2604
 
                                                {
2605
 
                                                        if (m_iShowMol != -1)
2606
 
                                                                m_iRefOrSec[z][0] = AskRangeInteger("    Take atom(s) at the base point from RM %s (0) or from OM %s (1)? [%d] ",0,1,z,((CMolecule*)g_oaMolecules[g_iFixMol])->m_sName,((CMolecule*)g_oaMolecules[m_iShowMol])->m_sName,z);
2607
 
                                                                        else m_iRefOrSec[z][0] = 0;
2608
 
                                                }
2609
 
                                                mprintf("      Please enter the atom(s) at the base point (e.g. C7): ");
2610
 
                                                inpprintf("! Please enter the atom(s) at the base point (e.g. C7):\n");
2611
 
                                                myget(buf);
2612
 
 
2613
 
                                                try { ag = new CAtomGroup(); } catch(...) { ag = NULL; }
2614
 
                                                if (ag == NULL) NewException((double)sizeof(CAtomGroup),__FILE__,__LINE__,__PRETTY_FUNCTION__);
2615
 
 
2616
 
                                                if (!ag->ParseAtoms((!m_iRefOrSec[z][0])?(CMolecule*)g_oaMolecules[g_iFixMol]:(CMolecule*)g_oaMolecules[m_iShowMol],buf))
2617
 
                                                {
2618
 
                                                        eprintf("Wrong input.\n");
2619
 
                                                        inpprintf("! Wrong input.\n");
2620
 
                                                        delete ag;
2621
 
                                                        goto _ax1;
2622
 
                                                }
2623
 
                                                m_oaVectors.Add(ag);
2624
 
                                                ti *= ag->m_iAtomGes;
2625
 
                                        }
2626
 
_ax2:                           if (z2 == 0)
2627
 
                                        {
2628
 
                                                if (m_iShowMol != -1)
2629
 
                                                        m_iRefOrSec[z][1] = AskRangeInteger("    Take 2nd atom(s) of normal plane from RM %s (0) or from OM %s (1)? [%d] ",0,1,z,((CMolecule*)g_oaMolecules[g_iFixMol])->m_sName,((CMolecule*)g_oaMolecules[m_iShowMol])->m_sName,z);
2630
 
                                                                else m_iRefOrSec[z][1] = 0;
2631
 
                                        }
2632
 
                                        mprintf("      Please enter the 2nd atom(s) of the normal plane (e.g. C7): ");
2633
 
                                        inpprintf("! Please enter the 2nd atom(s) of the normal plane (e.g. C7):\n");
2634
 
                                        myget(buf);
2635
 
 
2636
 
                                        try { ag = new CAtomGroup(); } catch(...) { ag = NULL; }
2637
 
                                        if (ag == NULL) NewException((double)sizeof(CAtomGroup),__FILE__,__LINE__,__PRETTY_FUNCTION__);
2638
 
 
2639
 
                                        if (!ag->ParseAtoms((!m_iRefOrSec[z][1])?(CMolecule*)g_oaMolecules[g_iFixMol]:(CMolecule*)g_oaMolecules[m_iShowMol],buf))
2640
 
                                        {
2641
 
                                                eprintf("Wrong input.\n");
2642
 
                                                inpprintf("! Wrong input.\n");
2643
 
                                                delete ag;
2644
 
                                                goto _ax2;
2645
 
                                        }
2646
 
                                        m_oaVectors.Add(ag);
2647
 
                                        ti *= ag->m_iAtomGes;
2648
 
_ax3:                           if (z2 == 0)
2649
 
                                        {
2650
 
                                                if (m_iShowMol != -1)
2651
 
                                                        m_iRefOrSec[z][2] = AskRangeInteger("    Take 3rd atom(s) of normal plane from RM %s (0) or from OM %s (1)? [%d] ",0,1,z,((CMolecule*)g_oaMolecules[g_iFixMol])->m_sName,((CMolecule*)g_oaMolecules[m_iShowMol])->m_sName,z);
2652
 
                                                                else m_iRefOrSec[z][2] = 0;
2653
 
                                        }
2654
 
                                        mprintf("      Please enter the 3rd atom(s) of the normal plane (e.g. C7): ");
2655
 
                                        inpprintf("! Please enter the 3rd atom(s) of the normal plane (e.g. C7):\n");
2656
 
                                        myget(buf);
2657
 
 
2658
 
                                        try { ag = new CAtomGroup(); } catch(...) { ag = NULL; }
2659
 
                                        if (ag == NULL) NewException((double)sizeof(CAtomGroup),__FILE__,__LINE__,__PRETTY_FUNCTION__);
2660
 
 
2661
 
                                        if (!ag->ParseAtoms((!m_iRefOrSec[z][2])?(CMolecule*)g_oaMolecules[g_iFixMol]:(CMolecule*)g_oaMolecules[m_iShowMol],buf))
2662
 
                                        {
2663
 
                                                eprintf("Wrong input.\n");
2664
 
                                                inpprintf("! Wrong input.\n");
2665
 
                                                delete ag;
2666
 
                                                goto _ax3;
2667
 
                                        }
2668
 
                                        m_oaVectors.Add(ag);
2669
 
                                        ti *= ag->m_iAtomGes;
2670
 
                                } else // IF ORTHO
2671
 
                                {
2672
 
/*                                      if (m_bSameFoot && (z == 1))
2673
 
                                        {
2674
 
                                                m_iRefOrSec[1][0] = m_iRefOrSec[0][0];
2675
 
                                                m_oaVectors.Add(NULL);
2676
 
                                        } else*/
2677
 
                                        {
2678
 
_ax4:                                   if (z2 == 0)
2679
 
                                                {
2680
 
                                                        if (m_iShowMol != -1)
2681
 
                                                                m_iRefOrSec[z][0] = AskRangeInteger("    Take atom(s) at the base point from RM %s (0) or from OM %s (1)? [%d] ",0,1,z,((CMolecule*)g_oaMolecules[g_iFixMol])->m_sName,((CMolecule*)g_oaMolecules[m_iShowMol])->m_sName,z);
2682
 
                                                                        else m_iRefOrSec[z][0] = 0;
2683
 
                                                }
2684
 
                                                mprintf("      Please enter the atom(s) at the base point (e.g. C7): ");
2685
 
                                                inpprintf("! Please enter the atom(s) at the base point (e.g. C7):\n");
2686
 
                                                myget(buf);
2687
 
 
2688
 
                                                try { ag = new CAtomGroup(); } catch(...) { ag = NULL; }
2689
 
                                                if (ag == NULL) NewException((double)sizeof(CAtomGroup),__FILE__,__LINE__,__PRETTY_FUNCTION__);
2690
 
 
2691
 
                                                if (!ag->ParseAtoms((!m_iRefOrSec[z][0])?(CMolecule*)g_oaMolecules[g_iFixMol]:(CMolecule*)g_oaMolecules[m_iShowMol],buf))
2692
 
                                                {
2693
 
                                                        eprintf("Wrong input.\n");
2694
 
                                                        inpprintf("! Wrong input.\n");
2695
 
                                                        delete ag;
2696
 
                                                        goto _ax4;
2697
 
                                                }
2698
 
                                                m_oaVectors.Add(ag);
2699
 
                                                ti *= ag->m_iAtomGes;
2700
 
                                        } // END IF NOT SAMEFOOT
2701
 
_ax5:                           if (z2 == 0)
2702
 
                                        {
2703
 
                                                if (m_iShowMol != -1)
2704
 
                                                        m_iRefOrSec[z][1] = AskRangeInteger("    Take atom(s) at the tip point from RM %s (0) or from OM %s (1)? [%d] ",0,1,z,((CMolecule*)g_oaMolecules[g_iFixMol])->m_sName,((CMolecule*)g_oaMolecules[m_iShowMol])->m_sName,z);
2705
 
                                                                else m_iRefOrSec[z][1] = 0;
2706
 
                                        }
2707
 
                                        mprintf("      Please enter the atom(s) at the tip point (e.g. C7): ");
2708
 
                                        inpprintf("! Please enter the atom(s) at the tip point (e.g. C7):\n");
2709
 
                                        myget(buf);
2710
 
 
2711
 
                                        try { ag = new CAtomGroup(); } catch(...) { ag = NULL; }
2712
 
                                        if (ag == NULL) NewException((double)sizeof(CAtomGroup),__FILE__,__LINE__,__PRETTY_FUNCTION__);
2713
 
 
2714
 
                                        if (!ag->ParseAtoms((!m_iRefOrSec[z][1])?(CMolecule*)g_oaMolecules[g_iFixMol]:(CMolecule*)g_oaMolecules[m_iShowMol],buf))
2715
 
                                        {
2716
 
                                                eprintf("Wrong input.\n");
2717
 
                                                inpprintf("! Wrong input.\n");
2718
 
                                                delete ag;
2719
 
                                                goto _ax5;
2720
 
                                        }
2721
 
                                        m_oaVectors.Add(ag);
2722
 
                                        ti *= ag->m_iAtomGes;
2723
 
                                        m_oaVectors.Add(NULL);
2724
 
                                } // END IF NOT ORTHO
2725
 
                        } else if (m_iVecType[z] == 1) // Dipol
2726
 
                        {
2727
 
                                if (m_iShowMol != -1)
2728
 
                                        m_iRefOrSec[z][0] = AskRangeInteger("    Take dipole vector from RM %s (0) or from OM %s (1)? [%d] ",0,1,z,((CMolecule*)g_oaMolecules[g_iFixMol])->m_sName,((CMolecule*)g_oaMolecules[m_iShowMol])->m_sName,z);
2729
 
                                                else m_iRefOrSec[z][0] = 0;
2730
 
                        } else if (m_iVecType[z] == 2) // Geschwindigkeit
2731
 
                        {
2732
 
_ax6:                   if (m_iShowMol != -1)
2733
 
                                        m_iRefOrSec[z][0] = AskRangeInteger("    Take velocity vector from RM %s (0) or from OM %s (1)? [%d] ",0,1,z,((CMolecule*)g_oaMolecules[g_iFixMol])->m_sName,((CMolecule*)g_oaMolecules[m_iShowMol])->m_sName,z);
2734
 
                                                else m_iRefOrSec[z][0] = 0;
2735
 
                                mprintf("      Velocity vector of which atoms to use (e.g. C7)? [#2] ");
2736
 
                                inpprintf("! Velocity vector of which atoms to use (e.g. C7)? [#2]\n");
2737
 
                                myget(buf);
2738
 
 
2739
 
                                try { ag = new CAtomGroup(); } catch(...) { ag = NULL; }
2740
 
                                if (ag == NULL) NewException((double)sizeof(CAtomGroup),__FILE__,__LINE__,__PRETTY_FUNCTION__);
2741
 
 
2742
 
                                if (strlen(buf)==0)
2743
 
                                {
2744
 
                                        if (!ag->ParseAtoms((!m_iRefOrSec[z][0])?(CMolecule*)g_oaMolecules[g_iFixMol]:(CMolecule*)g_oaMolecules[m_iShowMol],"#2"))
2745
 
                                        {
2746
 
                                                eprintf("Weird error.\n");
2747
 
                                                inpprintf("! Weird error.\n");
2748
 
                                                abort();
2749
 
                                        }
2750
 
                                } else if (!ag->ParseAtoms((!m_iRefOrSec[z][0])?(CMolecule*)g_oaMolecules[g_iFixMol]:(CMolecule*)g_oaMolecules[m_iShowMol],buf))
2751
 
                                {
2752
 
                                        eprintf("Wrong input.\n");
2753
 
                                        inpprintf("! Wrong input.\n");
2754
 
                                        delete ag;
2755
 
                                        goto _ax6;
2756
 
                                }
2757
 
                                m_oaVectors.Add(ag);
2758
 
                                ti *= ag->m_iAtomGes;
2759
 
                        } else if (m_iVecType[z] == 3) // Kraft
2760
 
                        {
2761
 
_ax7:                   if (m_iShowMol != -1)
2762
 
                                        m_iRefOrSec[z][0] = AskRangeInteger("    Take force vektor from RM %s (0) or from OM %s (1)? [%d] ",0,1,z,((CMolecule*)g_oaMolecules[g_iFixMol])->m_sName,((CMolecule*)g_oaMolecules[m_iShowMol])->m_sName,z);
2763
 
                                                else m_iRefOrSec[z][0] = 0;
2764
 
                                mprintf("      Force vector of which atoms to use (e.g. C7)? [#2] ");
2765
 
                                inpprintf("! Force vector of which atoms to use (e.g. C7)? [#2]\n");
2766
 
                                myget(buf);
2767
 
 
2768
 
                                try { ag = new CAtomGroup(); } catch(...) { ag = NULL; }
2769
 
                                if (ag == NULL) NewException((double)sizeof(CAtomGroup),__FILE__,__LINE__,__PRETTY_FUNCTION__);
2770
 
 
2771
 
                                if (strlen(buf)==0)
2772
 
                                {
2773
 
                                        if (!ag->ParseAtoms((!m_iRefOrSec[z][0])?(CMolecule*)g_oaMolecules[g_iFixMol]:(CMolecule*)g_oaMolecules[m_iShowMol],"#2"))
2774
 
                                        {
2775
 
                                                eprintf("Weird Error.\n");
2776
 
                                                inpprintf("! Weird Error.\n");
2777
 
                                                abort();
2778
 
                                        }
2779
 
                                } else if (!ag->ParseAtoms((!m_iRefOrSec[z][0])?(CMolecule*)g_oaMolecules[g_iFixMol]:(CMolecule*)g_oaMolecules[m_iShowMol],buf))
2780
 
                                {
2781
 
                                        eprintf("Wrong input.\n");
2782
 
                                        inpprintf("! Wrong input.\n");
2783
 
                                        delete ag;
2784
 
                                        goto _ax7;
2785
 
                                }
2786
 
                                m_oaVectors.Add(ag);
2787
 
                                ti *= ag->m_iAtomGes;
2788
 
                        }
2789
 
                } // END FOR 0..1
2790
 
                z2++;
2791
 
                m_iCombinations += ti;
2792
 
        } while (g_bAdvanced2?AskYesNo("\n    Add another set of vectors to this (!) ADF (y/n)? [no] ",false):false);
2793
 
 
2794
 
        ParseDeriv();
2795
 
 
2796
 
        switch(m_iDeriv)
2797
 
        {
2798
 
                case 0:
2799
 
                        m_fMinAngle = AskFloat("\n    Enter minimal angle between the vectors: [0 deg] ",0.0f);
2800
 
                        m_fMaxAngle = AskFloat("    Enter maximal angle between the vectors: [180 deg] ",180.0f);
2801
 
                        break;
2802
 
                case 1:
2803
 
                        if (m_bDerivAbs)
2804
 
                                m_fMinAngle = AskFloat("    Enter the minimal value of this d1-ADF in deg/ps: [0] ",0.0f);
2805
 
                                        else m_fMinAngle = AskFloat("    Enter the minimal value of this d1-ADF in deg/ps: [-10.0] ",-10.0f);
2806
 
                        m_fMaxAngle = AskFloat("    Enter the maximal value of this d1-ADF in deg/ps: [10.0] ",10.0f);
2807
 
                        break;
2808
 
                case 2:
2809
 
                        if (m_bDerivAbs)
2810
 
                                m_fMinAngle = AskFloat("    Enter the minimal value of this d2-ADF in deg/ps^2: [0] ",0.0f);
2811
 
                                        else m_fMinAngle = AskFloat("    Enter the minimal value of this d2-ADF in deg/ps^2: [-10.0] ",-10.0f);
2812
 
                        m_fMaxAngle = AskFloat("    Enter the maximal value of this d2-ADF in deg/ps^2: [10.0] ",10.0f);
2813
 
                        break;
2814
 
        }
2815
 
 
2816
 
/*      if (m_fMaxAngle <= 90.0f)
2817
 
                m_bFoldAngle = AskYesNo("    Should angles > 90 deg be \"mirrored\" (180 deg = 0 deg) (y/n)? [yes] ",true);
2818
 
                        else*/ m_bFoldAngle = false;
2819
 
        m_bCosine = (AskRangeInteger("    Plot ADF against angle (0) or against cosine (1)? [0] ",0,1,0)!=0);
2820
 
        if (m_bCosine)
2821
 
        {
2822
 
                m_fMinAngle = (float)cos(m_fMinAngle/180.0*Pi);
2823
 
                m_fMaxAngle = (float)cos(m_fMaxAngle/180.0*Pi);
2824
 
                if (m_fMinAngle > m_fMaxAngle)
2825
 
                {
2826
 
                        tf = m_fMinAngle;
2827
 
                        m_fMinAngle = m_fMaxAngle;
2828
 
                        m_fMaxAngle = tf;
2829
 
                }
2830
 
                mprintf("    The data range is %.2f to %.2f.\n",m_fMinAngle,m_fMaxAngle);
2831
 
        }
2832
 
        if (!m_bCosine)
2833
 
                m_bMirror = AskYesNo("    Force this ADF to be mirror-symmetric to the 90 deg line (y/n)? [no] ",false);
2834
 
                        else m_bMirror = false;
2835
 
        m_iResolution = AskUnsignedInteger("    Please enter the resolution (bin count) for this ADF: [100] ",100);
2836
 
 
2837
 
        if (g_bAdvanced2)
2838
 
                m_iHistogramRes = AskUnsignedInteger("    Please enter histogram resolution (0=no histogram): [5000] ",5000);
2839
 
                        m_iHistogramRes = 0;
2840
 
 
2841
 
        if (m_iShowMol != -1)
2842
 
                m_bStat = AskYesNo("    Apply cone correction (y/n)? [%c] ",!m_bCosine,(!m_bCosine)?'y':'n');
2843
 
                        else m_bStat = 0;
2844
 
/*      mprintf("\n    Save temporal development of this ADF (0=nein, 1=ja)? [0] ");
2845
 
        myget(buf);
2846
 
        m_bSaveAngle = (atoi(buf)!=0);*/
2847
 
        BuildName();
2848
 
        mprintf(WHITE,"\n<<< End of Angular Distribution Function <<<\n\n");
2849
 
        BTOUT;
2850
 
}
2851
 
 
2852
 
 
2853
 
void CDDF::Parse()
2854
 
{
2855
 
        BTIN;
2856
 
        char buf[256];
2857
 
        CAtomGroup *ag;
2858
 
        int z0, z, z2, i;
2859
 
        float tf;
2860
 
 
2861
 
        try { m_pDDF = new CDF(); } catch(...) { m_pDDF = NULL; }
2862
 
        if (m_pDDF == NULL) NewException((double)sizeof(CDF),__FILE__,__LINE__,__PRETTY_FUNCTION__);
2863
 
        
2864
 
        mprintf(WHITE,"\n>>> Dihedral Distribution Function >>>\n\n");
2865
 
        m_bClassical = AskYesNo("    Use \"simple\" (y) (4 atoms) or \"generalized\" (n) (3 vectors) Dihedrals? [yes] ",true);
2866
 
 
2867
 
        m_iCombinations = 1;
2868
 
        if (m_bClassical)
2869
 
        {
2870
 
                m_bOrtho[0] = false;
2871
 
                m_bOrtho[1] = false;
2872
 
                m_bOrtho[2] = false;
2873
 
                z0 = m_oaVectors.GetSize();
2874
 
                for (z=0;z<3;z++)
2875
 
                {
2876
 
                        try { ag = new CAtomGroup(); } catch(...) { ag = NULL; }
2877
 
                        if (ag == NULL) NewException((double)sizeof(CAtomGroup),__FILE__,__LINE__,__PRETTY_FUNCTION__);
2878
 
 
2879
 
                        m_oaVectors.Add(ag);
2880
 
 
2881
 
                        try { ag = new CAtomGroup(); } catch(...) { ag = NULL; }
2882
 
                        if (ag == NULL) NewException((double)sizeof(CAtomGroup),__FILE__,__LINE__,__PRETTY_FUNCTION__);
2883
 
 
2884
 
                        m_oaVectors.Add(ag);
2885
 
                        m_oaVectors.Add(NULL);
2886
 
                }
2887
 
                for (z=0;z<4;z++)
2888
 
                {
2889
 
_bx:            if (m_iShowMol != -1)
2890
 
                                i = AskRangeInteger("    Take the %d. atom from RM %s (0) or from OM %s (1)? [0] ",0,1,0,z+1,((CMolecule*)g_oaMolecules[g_iFixMol])->m_sName,((CMolecule*)g_oaMolecules[m_iShowMol])->m_sName);
2891
 
                                        else i = 0;
2892
 
                        switch(z)
2893
 
                        {
2894
 
                                case 0:
2895
 
                                        m_iRefOrSec[0][1] = i;
2896
 
                                        break;
2897
 
                                case 1:
2898
 
                                        m_iRefOrSec[0][0] = i;
2899
 
                                        m_iRefOrSec[2][0] = i;
2900
 
                                        break;
2901
 
                                case 2:
2902
 
                                        m_iRefOrSec[2][1] = i;
2903
 
                                        m_iRefOrSec[1][0] = i;
2904
 
                                        break;
2905
 
                                case 3:
2906
 
                                        m_iRefOrSec[1][1] = i;
2907
 
                                        break;
2908
 
                        }
2909
 
                        mprintf("      Enter the %d. atom(s) (e.g. C7): ",z+1);
2910
 
                        inpprintf("! Enter the %d. atom(s) (e.g. C7):\n",z+1);
2911
 
                        myget(buf);
2912
 
                        switch(z)
2913
 
                        {
2914
 
                                case 0:
2915
 
                                        if (!((CAtomGroup*)m_oaVectors[z0+0*3+1])->ParseAtoms((!m_iRefOrSec[0][1])?(CMolecule*)g_oaMolecules[g_iFixMol]:(CMolecule*)g_oaMolecules[m_iShowMol],buf))
2916
 
                                        {
2917
 
                                                eprintf("Wrong input.\n");
2918
 
                                                inpprintf("! Wrong input.\n");
2919
 
                                                goto _bx;
2920
 
                                        }
2921
 
                                        m_iCombinations *= ((CAtomGroup*)m_oaVectors[z0+0*3+1])->m_iAtomGes;
2922
 
                                        break;
2923
 
                                case 1:
2924
 
                                        if (!((CAtomGroup*)m_oaVectors[z0+0*3+0])->ParseAtoms((!m_iRefOrSec[0][0])?(CMolecule*)g_oaMolecules[g_iFixMol]:(CMolecule*)g_oaMolecules[m_iShowMol],buf))
2925
 
                                        {
2926
 
                                                eprintf("Wrong input.\n");
2927
 
                                                inpprintf("! Wrong input.\n");
2928
 
                                                goto _bx;
2929
 
                                        }
2930
 
                                        if (!((CAtomGroup*)m_oaVectors[z0+2*3+0])->ParseAtoms((!m_iRefOrSec[2][0])?(CMolecule*)g_oaMolecules[g_iFixMol]:(CMolecule*)g_oaMolecules[m_iShowMol],buf))
2931
 
                                        {
2932
 
                                                eprintf("Wrong input.\n");
2933
 
                                                inpprintf("! Wrong input.\n");
2934
 
                                                goto _bx;
2935
 
                                        }
2936
 
                                        m_iCombinations *= ((CAtomGroup*)m_oaVectors[z0+0*3+0])->m_iAtomGes;
2937
 
                                        m_iCombinations *= ((CAtomGroup*)m_oaVectors[z0+0*3+0])->m_iAtomGes;
2938
 
                                        break;
2939
 
                                case 2:
2940
 
                                        if (!((CAtomGroup*)m_oaVectors[z0+2*3+1])->ParseAtoms((!m_iRefOrSec[2][1])?(CMolecule*)g_oaMolecules[g_iFixMol]:(CMolecule*)g_oaMolecules[m_iShowMol],buf))
2941
 
                                        {
2942
 
                                                eprintf("Wrong input.\n");
2943
 
                                                inpprintf("! Wrong input.\n");
2944
 
                                                goto _bx;
2945
 
                                        }
2946
 
                                        if (!((CAtomGroup*)m_oaVectors[z0+1*3+0])->ParseAtoms((!m_iRefOrSec[1][0])?(CMolecule*)g_oaMolecules[g_iFixMol]:(CMolecule*)g_oaMolecules[m_iShowMol],buf))
2947
 
                                        {
2948
 
                                                eprintf("Wrong input.\n");
2949
 
                                                inpprintf("! Wrong input.\n");
2950
 
                                                goto _bx;
2951
 
                                        }
2952
 
                                        m_iCombinations *= ((CAtomGroup*)m_oaVectors[z0+2*3+1])->m_iAtomGes;
2953
 
                                        m_iCombinations *= ((CAtomGroup*)m_oaVectors[z0+2*3+1])->m_iAtomGes;
2954
 
                                        break;
2955
 
                                case 3:
2956
 
                                        if (!((CAtomGroup*)m_oaVectors[z0+1*3+1])->ParseAtoms((!m_iRefOrSec[1][1])?(CMolecule*)g_oaMolecules[g_iFixMol]:(CMolecule*)g_oaMolecules[m_iShowMol],buf))
2957
 
                                        {
2958
 
                                                eprintf("Wrong input.\n");
2959
 
                                                inpprintf("! Wrong input.\n");
2960
 
                                                goto _bx;
2961
 
                                        }
2962
 
                                        m_iCombinations *= ((CAtomGroup*)m_oaVectors[z0+1*3+1])->m_iAtomGes;
2963
 
                                        break;
2964
 
                        }
2965
 
                }
2966
 
        } else // NONCLASSIC
2967
 
        {
2968
 
                mprintf("\nYou now have to define 3 vectors:\n");
2969
 
                mprintf("The 1st and 2nd vector are projected onto the normal plane of the 3rd vector.\n");
2970
 
                mprintf("The angle between the two projected vectors in the plane is evaluated.\n");
2971
 
                for (z=0;z<3;z++)
2972
 
                {
2973
 
                        mprintf(WHITE,"\n  * Vector %d\n",z+1);
2974
 
                        m_bOrtho[z] = (AskRangeInteger("    Shall the %d. vector connect 2 points (0) or be orthogonal to a plane (1)? [0] ",0,1,0,z+1) != 0);
2975
 
                        if (m_bOrtho[z])
2976
 
                        {
2977
 
                                for (z2=0;z2<3;z2++)
2978
 
                                {
2979
 
                                        try { ag = new CAtomGroup(); } catch(...) { ag = NULL; }
2980
 
                                        if (ag == NULL) NewException((double)sizeof(CAtomGroup),__FILE__,__LINE__,__PRETTY_FUNCTION__);
2981
 
 
2982
 
_by:                            if (m_iShowMol != -1)
2983
 
                                                m_iRefOrSec[z][z2] = AskRangeInteger("    Take the %d. atom(s) of the plane from RM %s (0) or from OM %s (1)? [0] ",0,1,0,z2+1,((CMolecule*)g_oaMolecules[g_iFixMol])->m_sName,((CMolecule*)g_oaMolecules[m_iShowMol])->m_sName);
2984
 
                                                        else m_iRefOrSec[z][z2] = 0;
2985
 
                                        mprintf("      Please enter the %d. atom(s) (e.g. C7): ",z2+1);
2986
 
                                        inpprintf("! Please enter the %d. atom(s) (e.g. C7):\n",z2+1);
2987
 
                                        myget(buf);
2988
 
                                        if (!ag->ParseAtoms((!m_iRefOrSec[z][z2])?(CMolecule*)g_oaMolecules[g_iFixMol]:(CMolecule*)g_oaMolecules[m_iShowMol],buf))
2989
 
                                        {
2990
 
                                                eprintf("Wrong input.\n");
2991
 
                                                inpprintf("! Wrong input.\n");
2992
 
                                                goto _by;
2993
 
                                        }
2994
 
                                        m_iCombinations *= ag->m_iAtomGes;
2995
 
                                        m_oaVectors.Add(ag);
2996
 
                                }
2997
 
                        } else // Ortho
2998
 
                        {
2999
 
                                for (z2=0;z2<2;z2++)
3000
 
                                {
3001
 
                                        try { ag = new CAtomGroup(); } catch(...) { ag = NULL; }
3002
 
                                        if (ag == NULL) NewException((double)sizeof(CAtomGroup),__FILE__,__LINE__,__PRETTY_FUNCTION__);
3003
 
 
3004
 
_bz:                            if (m_iShowMol != -1)
3005
 
                                                m_iRefOrSec[z][z2] = AskRangeInteger("    Take the %d. atom(s) of the vector from RM %s (0) or from OM %s (1)? [0] ",0,1,0,z2+1,((CMolecule*)g_oaMolecules[g_iFixMol])->m_sName,((CMolecule*)g_oaMolecules[m_iShowMol])->m_sName);
3006
 
                                                        else m_iRefOrSec[z][z2] = 0;
3007
 
                                        mprintf("      Please enter the %d. atom(s) (e.g. C7): ",z2+1);
3008
 
                                        inpprintf("! Please enter the %d. atom(s) (e.g. C7):\n",z2+1);
3009
 
                                        myget(buf);
3010
 
                                        if (!ag->ParseAtoms((!m_iRefOrSec[z][z2])?(CMolecule*)g_oaMolecules[g_iFixMol]:(CMolecule*)g_oaMolecules[m_iShowMol],buf))
3011
 
                                        {
3012
 
                                                eprintf("Wrong input.\n");
3013
 
                                                inpprintf("! Wrong input.\n");
3014
 
                                                goto _bz;
3015
 
                                        }
3016
 
                                        m_iCombinations *= ag->m_iAtomGes;
3017
 
                                        m_oaVectors.Add(ag);
3018
 
                                }
3019
 
                                m_oaVectors.Add(NULL);
3020
 
                        } // ENDIF ORTHO
3021
 
                } // END FOR
3022
 
        } // END IF NONCLASSIC
3023
 
 
3024
 
/*      mprintf("\n");
3025
 
        mprintf("    The \"classical\" dihedral angle is defined for a range of 0 ... 180 deg.\n\n");
3026
 
        m_bAbs = !AskYesNo("    Do you want to extend the range to -180 ... +180 deg (y/n)? [no] ",false);*/
3027
 
 
3028
 
        mprintf("\n");
3029
 
        mprintf("    Per default, the dihedral angle is defined in a range of -180 ... 180 deg.\n\n");
3030
 
        m_bPositive = AskYesNo("    Use range of 0 ... 360 deg instead (e.g. -90 deg becomes 270 deg, ...) (y/n)? [no] ",false);
3031
 
        m_bAbs = false;
3032
 
        mprintf("\n");
3033
 
 
3034
 
        ParseDeriv();
3035
 
 
3036
 
        switch(m_iDeriv)
3037
 
        {
3038
 
                case 0:
3039
 
                        if (m_bPositive)
3040
 
                        {
3041
 
                                m_fMinAngle = AskFloat("\n    Enter minimal dihedral angle to observe:   [0 deg] ",0);
3042
 
                                m_fMaxAngle = AskFloat("    Enter maximal dihedral angle to observe: [360 deg] ",360.0f);
 
1
/*****************************************************************************
 
2
    TRAVIS - Trajectory Analyzer and Visualizer
 
3
    http://www.travis-analyzer.de/
 
4
 
 
5
    Copyright (c) 2009-2014 Martin Brehm
 
6
                  2012-2014 Martin Thomas
 
7
 
 
8
    This file written by Martin Brehm.
 
9
 
 
10
    This program is free software: you can redistribute it and/or modify
 
11
    it under the terms of the GNU General Public License as published by
 
12
    the Free Software Foundation, either version 3 of the License, or
 
13
    (at your option) any later version.
 
14
 
 
15
    This program is distributed in the hope that it will be useful,
 
16
    but WITHOUT ANY WARRANTY; without even the implied warranty of
 
17
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
18
    GNU General Public License for more details.
 
19
 
 
20
    You should have received a copy of the GNU General Public License
 
21
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
22
*****************************************************************************/
 
23
 
 
24
#include "moltools.h"
 
25
#include "travis.h"
 
26
#include "maintools.h"
 
27
#include "plproj.h"
 
28
 
 
29
 
 
30
 
 
31
CAtom::CAtom()
 
32
{
 
33
        m_pElement = NULL;
 
34
        m_bExclude = false;
 
35
        m_pMergedTo = NULL;
 
36
        m_iIndex = -1;
 
37
}
 
38
 
 
39
 
 
40
CAtom::~CAtom()
 
41
{
 
42
}
 
43
 
 
44
 
 
45
CVirtualAtom::CVirtualAtom()
 
46
{
 
47
        m_faWeight.SetName("CVirtualAtom::m_faWeight");
 
48
}
 
49
 
 
50
 
 
51
CVirtualAtom::~CVirtualAtom()
 
52
{
 
53
}
 
54
 
 
55
 
 
56
CMolecule::CMolecule()
 
57
{
 
58
        m_iWannierCount = 0;
 
59
        m_sName = NULL;
 
60
        m_fCharge = 0;
 
61
        m_bPseudo = false;
 
62
        m_bChargesAssigned = false;
 
63
 
 
64
        m_baAtomIndex.SetName("CMolecule::m_baAtomIndex");
 
65
        m_waAtomCount.SetName("CMolecule::m_waAtomCount");
 
66
        m_laSingleMolIndex.SetName("CMolecule::m_laSingleMolIndex");
 
67
        m_laVirtualAtoms.SetName("CMolecule::m_laVirtualAtoms");
 
68
        m_oaNewNumbers.SetName("CMolecule::m_oaNewNumbers");
 
69
        m_oaRingAtomTypes.SetName("CMolecule::m_oaRingAtomTypes");
 
70
        m_oaRingAtoms.SetName("CMolecule::m_oaRingAtoms");
 
71
        m_oaCharges.SetName("CMolecule::m_oaCharges");
 
72
}
 
73
 
 
74
 
 
75
CMolecule::~CMolecule()
 
76
{
 
77
        if (m_sName != NULL)
 
78
        {
 
79
                delete[] m_sName;
 
80
                m_sName = NULL;
 
81
        }
 
82
}
 
83
 
 
84
 
 
85
CMolAtom::CMolAtom()
 
86
{
 
87
        m_oaBonds.SetName("CMolAtom::m_oaBonds");
 
88
}
 
89
 
 
90
 
 
91
CMolAtom::~CMolAtom()
 
92
{
 
93
}
 
94
 
 
95
 
 
96
CSingleMolecule::CSingleMolecule()
 
97
{
 
98
        m_bPseudo = false;
 
99
 
 
100
        m_oaBondGroups.SetName("CSingleMolecule::m_oaBondGroups");
 
101
        m_oaBonds.SetName("CSingleMolecule::m_oaBonds");
 
102
        m_oaAngleGroups.SetName("CSingleMolecule::m_oaAngleGroups");
 
103
        m_oaAngles.SetName("CSingleMolecule::m_oaAngles");
 
104
        m_oaRings.SetName("CSingleMolecule::m_oaRings");
 
105
        m_laBonds.SetName("CSingleMolecule::m_laBonds");
 
106
        m_laWannier.SetName("CSingleMolecule::m_laWannier");
 
107
        m_oaAtomOffset.SetName("CSingleMolecule::m_oaAtomOffset");
 
108
        m_oaMolAtoms.SetName("CSingleMolecule::m_oaMolAtoms");
 
109
        m_baAtomIndex.SetName("CSingleMolecule::m_baAtomIndex"); 
 
110
}
 
111
 
 
112
 
 
113
CSingleMolecule::~CSingleMolecule()
 
114
{
 
115
}
 
116
 
 
117
 
 
118
CADF::CADF()
 
119
{
 
120
        m_pADF = NULL;
 
121
        m_oaVectors.SetName("CADF::m_oaVectors");
 
122
        m_faACF.SetName("CADF::m_faACF");
 
123
        m_faMinMaxAngle.SetName("CADF::m_faMinMaxAngle");
 
124
}
 
125
 
 
126
 
 
127
CADF::~CADF()
 
128
{
 
129
}
 
130
 
 
131
 
 
132
CDDF::CDDF()
 
133
{
 
134
        m_bRotate = false;
 
135
        m_oaVectors.SetName("CDDF::m_oaVectors");
 
136
        m_faLastData.SetName("CDDF::m_faLastData"); 
 
137
        m_laRotation.SetName("CDDF::m_laRotation");
 
138
        m_faACF.SetName("CDDF::m_faACF");
 
139
}
 
140
 
 
141
 
 
142
CDDF::~CDDF()
 
143
{
 
144
}
 
145
 
 
146
 
 
147
CMSD::CMSD()
 
148
{
 
149
        m_oaCache.SetName("CMSD::m_oaCache");
 
150
}
 
151
 
 
152
 
 
153
CMSD::~CMSD()
 
154
{
 
155
}
 
156
 
 
157
 
 
158
CVHDF::CVHDF()
 
159
{
 
160
        m_sName = NULL;
 
161
        m_sShortName = NULL;
 
162
        m_pVHDF = NULL;
 
163
        m_oaVectors.SetName("CVHDF::m_oaVectors");
 
164
}
 
165
 
 
166
 
 
167
CVHDF::~CVHDF()
 
168
{
 
169
        if (m_sName != NULL)
 
170
        {
 
171
                delete[] m_sName;
 
172
                m_sName = NULL;
 
173
        }
 
174
        if (m_sShortName != NULL)
 
175
        {
 
176
                delete[] m_sShortName;
 
177
                m_sShortName = NULL;
 
178
        }
 
179
        if (m_pVHDF != NULL)
 
180
        {
 
181
                delete m_pVHDF;
 
182
                m_pVHDF = NULL;
 
183
        }
 
184
}
 
185
 
 
186
 
 
187
CRDF::CRDF()
 
188
{
 
189
        m_fDist = NULL;
 
190
        m_pRDF = NULL;
 
191
        m_bProbDens = false;
 
192
        m_faMinMaxDist.SetName("CRDF::m_faMinMaxDist");
 
193
        m_oaVectors.SetName("CRDF::m_oaVectors");
 
194
        m_faACF.SetName("CRDF::m_faACF");
 
195
}
 
196
 
 
197
 
 
198
CPlDF::CPlDF()
 
199
{
 
200
        m_pPlDF = NULL;
 
201
        m_oaVectors.SetName("CPlDF::m_oaVectors");
 
202
        m_faACF.SetName("CPlDF::m_faACF");
 
203
}
 
204
 
 
205
 
 
206
CLiDF::CLiDF()
 
207
{
 
208
        m_pLiDF = NULL;
 
209
        m_oaVectors.SetName("CLiDF::m_oaVectors");
 
210
        m_faACF.SetName("CLiDF::m_faACF");
 
211
}
 
212
 
 
213
 
 
214
CRDF::~CRDF()
 
215
{
 
216
        if (m_sName != NULL)
 
217
        {
 
218
                delete[] m_sName;
 
219
                m_sName = NULL;
 
220
        }
 
221
        if (m_sShortName != NULL)
 
222
        {
 
223
                delete[] m_sShortName;
 
224
                m_sShortName = NULL;
 
225
        }
 
226
        if (m_fDist != NULL)
 
227
        {
 
228
                delete[] m_fDist;
 
229
                m_fDist = NULL;
 
230
        }
 
231
        if (m_pRDF != NULL)
 
232
        {
 
233
                delete m_pRDF;
 
234
                m_pRDF = NULL;
 
235
        }
 
236
        if (m_faData != NULL)
 
237
        {
 
238
                delete[] m_faData;
 
239
                m_faData = NULL;
 
240
        }
 
241
}
 
242
 
 
243
 
 
244
CDensDF::CDensDF()
 
245
{
 
246
        m_pDensDF = NULL;
 
247
}
 
248
 
 
249
 
 
250
CDensDF::~CDensDF()
 
251
{
 
252
        if (m_sName != NULL)
 
253
        {
 
254
                delete[] m_sName;
 
255
                m_sName = NULL;
 
256
        }
 
257
        if (m_sShortName != NULL)
 
258
        {
 
259
                delete[] m_sShortName;
 
260
                m_sShortName = NULL;
 
261
        }
 
262
        if (m_pDensDF != NULL)
 
263
        {
 
264
                delete m_pDensDF;
 
265
                m_pDensDF = NULL;
 
266
        }
 
267
}
 
268
 
 
269
 
 
270
CVDF::CVDF()
 
271
{
 
272
        m_faACF.SetName("CVDF::m_faACF");
 
273
}
 
274
 
 
275
 
 
276
CVDF::~CVDF()
 
277
{
 
278
}
 
279
 
 
280
 
 
281
CDipDF::CDipDF()
 
282
{
 
283
        m_faACF.SetName("CDipDF::m_faACF");
 
284
}
 
285
 
 
286
 
 
287
CDipDF::~CDipDF()
 
288
{
 
289
}
 
290
 
 
291
 
 
292
CSDF::CSDF()
 
293
{
 
294
        m_pCutPlane = NULL;
 
295
        m_fPosCounter = 0;
 
296
        m_fAtom2PosX = 0;
 
297
        m_fAtom3PosX = 0;
 
298
        m_fAtom3PosY = 0;
 
299
}
 
300
 
 
301
 
 
302
CSDF::~CSDF()
 
303
{
 
304
}
 
305
 
 
306
 
 
307
CCDF::CCDF()
 
308
{
 
309
        m_bAxisDivide = false;
 
310
}
 
311
 
 
312
 
 
313
CCDF::~CCDF()
 
314
{
 
315
}
 
316
 
 
317
 
 
318
CConditionSubGroup::CConditionSubGroup()
 
319
{
 
320
        m_fPassed = 0;
 
321
        m_fTotal = 0;
 
322
        m_oaConditions.SetName("CConditionSubGroup::m_oaConditions");
 
323
}
 
324
 
 
325
 
 
326
CConditionSubGroup::~CConditionSubGroup()
 
327
{
 
328
}
 
329
 
 
330
 
 
331
CConditionGroup::CConditionGroup()
 
332
{
 
333
        m_pTable = NULL;
 
334
        m_bInactive = false;
 
335
        m_fPassed = 0;
 
336
        m_fTotal = 0;
 
337
        m_iPassCounter = NULL;
 
338
        m_bAlwaysTrue = NULL;
 
339
        m_oaConditionSubGroups.SetName("CConditionGroup::m_oaConditionSubGroups");
 
340
}
 
341
 
 
342
 
 
343
CConditionGroup::~CConditionGroup()
 
344
{
 
345
}
 
346
 
 
347
 
 
348
bool ContainsDigit(const char *s)
 
349
{
 
350
        if (strcspn(s,"0123456789") != strlen(s))
 
351
                return true;
 
352
        return false;
 
353
}
 
354
 
 
355
 
 
356
void ReplaceDigits(char *s)
 
357
{
 
358
        char buf[32];
 
359
        char *p, *q;
 
360
        bool b;
 
361
 
 
362
        p = s;
 
363
        q = buf;
 
364
        b = false;
 
365
        while (*p != 0)
 
366
        {
 
367
                if (b)
 
368
                {
 
369
                        switch(*p)
 
370
                        {
 
371
                                case '1': *q = 'a'; break;
 
372
                                case '2': *q = 'b'; break;
 
373
                                case '3': *q = 'c'; break;
 
374
                                case '4': *q = 'd'; break;
 
375
                                case '5': *q = 'e'; break;
 
376
                                case '6': *q = 'f'; break;
 
377
                                case '7': *q = 'g'; break;
 
378
                                case '8': *q = 'h'; break;
 
379
                                case '9': *q = 'i'; break;
 
380
                                case '0': *q = 'z'; break;
 
381
                                default: *q = *p;
 
382
                        }
 
383
                } else
 
384
                {
 
385
                        switch(*p)
 
386
                        {
 
387
                                case '1': b = true; *q = '_'; q++; *q = 'a'; break;
 
388
                                case '2': b = true; *q = '_'; q++; *q = 'b'; break;
 
389
                                case '3': b = true; *q = '_'; q++; *q = 'c'; break;
 
390
                                case '4': b = true; *q = '_'; q++; *q = 'd'; break;
 
391
                                case '5': b = true; *q = '_'; q++; *q = 'e'; break;
 
392
                                case '6': b = true; *q = '_'; q++; *q = 'f'; break;
 
393
                                case '7': b = true; *q = '_'; q++; *q = 'g'; break;
 
394
                                case '8': b = true; *q = '_'; q++; *q = 'h'; break;
 
395
                                case '9': b = true; *q = '_'; q++; *q = 'i'; break;
 
396
                                case '0': b = true; *q = '_'; q++; *q = 'z'; break;
 
397
                                default: *q = *p;
 
398
                        }
 
399
                }
 
400
                p++;
 
401
                q++;
 
402
        }
 
403
        *q = 0;
 
404
        strcpy(s,buf);
 
405
}
 
406
 
 
407
 
 
408
void xAddAtom(const char *s)
 
409
{
 
410
        BTIN;
 
411
        int z;
 
412
        CAtom *a;
 
413
        char buf[64];
 
414
 
 
415
        if (g_oaAtoms.GetSize() >= 254)
 
416
        {
 
417
                eprintf("More than 254 different atom types not supported.\n");
 
418
                return;
 
419
        }
 
420
 
 
421
        strcpy(buf,s);
 
422
        ReplaceDigits(buf);
 
423
 
 
424
//      printf("AddAtom: \"%s\".\n",s);
 
425
        for (z=0;z<g_oaAtoms.GetSize();z++)
 
426
        {
 
427
                if (mystricmp(buf,((CAtom*)g_oaAtoms[z])->m_sName)==0)
 
428
                {
 
429
                        ((CAtom*)g_oaAtoms[z])->m_iCount++;
 
430
                        BTOUT; 
 
431
                        return;
 
432
                }
 
433
        }
 
434
        if (ContainsDigit(s))
 
435
                eprintf("Digits in element labels not allowed. Renaming %s to %s.\n",s,buf);
 
436
 
 
437
        try { a = new CAtom(); } catch(...) { a = NULL; }
 
438
        if (a == NULL) NewException((double)sizeof(CAtom),__FILE__,__LINE__,__PRETTY_FUNCTION__);
 
439
        
 
440
        a->m_iIndex = g_oaAtoms.GetSize();
 
441
        strcpy(a->m_sName,buf);
 
442
        if (islower(a->m_sName[0]))
 
443
                a->m_sName[0] = toupper(a->m_sName[0]);
 
444
        if (strlen(a->m_sName) > 1)
 
445
                if (isupper(a->m_sName[1]))
 
446
                        a->m_sName[1] = tolower(a->m_sName[1]);
 
447
        a->m_iCount = 1;
 
448
/*      if (s[0] != '#')
 
449
        {*/
 
450
                a->m_pElement = FindElement(buf,false);
 
451
                if (a->m_pElement == NULL)
 
452
                {
 
453
                        try { a->m_pElement = new CElement(); } catch(...) { a->m_pElement = NULL; }
 
454
                        if (a->m_pElement == NULL) NewException((double)sizeof(CElement),__FILE__,__LINE__,__PRETTY_FUNCTION__);
 
455
                        
 
456
                        try { a->m_pElement->m_sLabel = new char[strlen(a->m_sName)+1]; } catch(...) { a->m_pElement->m_sLabel = NULL; }
 
457
                        if (a->m_pElement->m_sLabel == NULL) NewException((double)(strlen(a->m_sName)+1)*sizeof(char),__FILE__,__LINE__,__PRETTY_FUNCTION__);
 
458
                        
 
459
                        strcpy(a->m_pElement->m_sLabel,a->m_sName);
 
460
                }
 
461
/*              a->m_fMass = AtomMass(s);
 
462
                a->m_fRadius = AtomRadius(s);
 
463
                a->m_iOrd = AtomOrd(s);*/
 
464
//              a->m_fVDWRadius = AtomVDWRadius(s);
 
465
/*      } else
 
466
        {
 
467
                a->m_fMass = 0.0f;
 
468
                a->m_fRadius = 0.0f;
 
469
                a->m_iOrd = 0;
 
470
//              a->m_fVDWRadius = 0.0f;
 
471
        }*/
 
472
        g_oaAtoms.Add(a);
 
473
//      g_pAtoms[g_iElementCount].Offset = offset;
 
474
//      printf("Fuege Atom %s an Stelle %d neu hinzu. Der Offset ist %d.\n",s,g_iAtomCount,offset);
 
475
//      g_iElementCount++;
 
476
        BTOUT; 
 
477
}
 
478
 
 
479
 
 
480
void CSingleMolecule::Dump()
 
481
{
 
482
        BTIN;
 
483
        int z, z2;
 
484
        mprintf("### Single Molecule Dump ###\n");
 
485
        mprintf("%d Elemente.\n",m_baAtomIndex.GetSize());
 
486
        for (z=0;z<m_baAtomIndex.GetSize();z++)
 
487
        {
 
488
                mprintf(" * Element %d: %s. %d Vertreter *\n    Atome ",z+1,((CAtom*)g_oaAtoms[m_baAtomIndex[z]])->m_sName,((CxIntArray*)m_oaAtomOffset[z])->GetSize());
 
489
                for (z2=0;z2<((CxIntArray*)m_oaAtomOffset[z])->GetSize();z2++)
 
490
                {
 
491
                        mprintf("%d",((CxIntArray*)m_oaAtomOffset[z])->GetAt(z2));
 
492
                        if (z2 < ((CxIntArray*)m_oaAtomOffset[z])->GetSize()-1)
 
493
                                mprintf(", ");
 
494
                }
 
495
                mprintf("\n");
 
496
        }
 
497
        BTOUT;
 
498
}
 
499
 
 
500
 
 
501
void CMolecule::Dump()
 
502
{
 
503
        BTIN;
 
504
        int z;
 
505
        mprintf("### Molecule Type Dump ###\n");
 
506
        mprintf("%d Elemente.\n",m_baAtomIndex.GetSize());
 
507
        for (z=0;z<m_baAtomIndex.GetSize();z++)
 
508
                mprintf(" * Element %d: %s. %d Vertreter *\n",z+1,((CAtom*)g_oaAtoms[m_baAtomIndex[z]])->m_sName,m_waAtomCount[z]);
 
509
        BTOUT;
 
510
}
 
511
 
 
512
 
 
513
void CADF::BuildName()
 
514
{
 
515
        BTIN;
 
516
        int z, z2;
 
517
        char tmp[256];
 
518
        CAtomGroup *ag;
 
519
 
 
520
        tmp[0] = 0;
 
521
        if (m_iDeriv != 0)
 
522
                sprintf(tmp,"deriv%d_",m_iDeriv);
 
523
        for (z2=0;z2<m_oaVectors.GetSize()/6;z2++)
 
524
        {
 
525
                for (z=0;z<2;z++)
 
526
                {
 
527
                        strcat(tmp,"[");
 
528
                        if (m_iVecType[z] == 0) // Position
 
529
                        {
 
530
                                if (m_bOrtho[z])
 
531
                                {
 
532
/*                                      if (m_bSameFoot && (z == 1))
 
533
                                                ag = (CAtomGroup*)m_oaVectors[z2*6];
 
534
                                                        else */ag = (CAtomGroup*)m_oaVectors[z2*6+z*3];
 
535
                                        strcat(tmp,ag->m_sName);
 
536
                                        if (m_iRefOrSec[z][0])
 
537
                                                strcat(tmp,"o_");
 
538
                                                        else strcat(tmp,"r_");
 
539
                                        strcat(tmp,((CAtomGroup*)m_oaVectors[z2*6+z*3+1])->m_sName);
 
540
                                        if (m_iRefOrSec[z][1])
 
541
                                                strcat(tmp,"o_");
 
542
                                                        else strcat(tmp,"r_");
 
543
                                        strcat(tmp,((CAtomGroup*)m_oaVectors[z2*6+z*3+2])->m_sName);
 
544
                                        if (m_iRefOrSec[z][2])
 
545
                                                strcat(tmp,"o");
 
546
                                                        else strcat(tmp,"r");
 
547
                                } else
 
548
                                {
 
549
                        /*              if (m_bSameFoot && (z == 1))
 
550
                                                ag = (CAtomGroup*)m_oaVectors[z2*6];
 
551
                                                        else */ag = (CAtomGroup*)m_oaVectors[z2*6+z*3];
 
552
                                        strcat(tmp,ag->m_sName);
 
553
                                        if (m_iRefOrSec[z][0])
 
554
                                                strcat(tmp,"o_");
 
555
                                                        else strcat(tmp,"r_");
 
556
                                        strcat(tmp,((CAtomGroup*)m_oaVectors[z2*6+z*3+1])->m_sName);
 
557
                                        if (m_iRefOrSec[z][1])
 
558
                                                strcat(tmp,"o");
 
559
                                                        else strcat(tmp,"r");
 
560
                                }
 
561
                        } else if (m_iVecType[z] == 1) // Dipol
 
562
                        {
 
563
                                strcat(tmp,"dip_");
 
564
                                strcat(tmp,(m_iRefOrSec[z][0]!=0)?((CMolecule*)g_oaMolecules[m_iShowMol])->m_sName:((CMolecule*)g_oaMolecules[g_iFixMol])->m_sName);
 
565
                        } else if (m_iVecType[z] == 2) // Geschwindigkeit
 
566
                        {
 
567
                                strcat(tmp,"vel_");
 
568
                                strcat(tmp,((CAtomGroup*)m_oaVectors[z*3])->m_sName);
 
569
                        } else if (m_iVecType[z] == 3) // Kraft
 
570
                        {
 
571
                                strcat(tmp,"frc_");
 
572
                                strcat(tmp,((CAtomGroup*)m_oaVectors[z*3])->m_sName);
 
573
                        }
 
574
                        if (z == 0)
 
575
                                strcat(tmp,"]-");
 
576
                                        else strcat(tmp,"]");
 
577
                }
 
578
                if (z2<(m_oaVectors.GetSize()/6)-1)
 
579
                        strcat(tmp,"_");
 
580
        }
 
581
 
 
582
        try { m_sShortName = new char[strlen(tmp)+1]; } catch(...) { m_sShortName = NULL; }
 
583
        if (m_sShortName == NULL) NewException((double)(strlen(tmp)+1)*sizeof(char),__FILE__,__LINE__,__PRETTY_FUNCTION__);
 
584
        
 
585
        strcpy(m_sShortName,tmp);
 
586
        if (m_iShowMol != -1)
 
587
                sprintf(tmp,"%s_%s%d_%s_",((CMolecule*)g_oaMolecules[g_iFixMol])->m_sName,((CAtom*)g_oaAtoms[g_iFixRealAtomType[0]])->m_sName,g_iFixAtom[0]+1,((CMolecule*)g_oaMolecules[m_iShowMol])->m_sName);
 
588
                        else sprintf(tmp,"%s_%s%d_",((CMolecule*)g_oaMolecules[g_iFixMol])->m_sName,((CAtom*)g_oaAtoms[g_iFixRealAtomType[0]])->m_sName,g_iFixAtom[0]+1);
 
589
        strcat(tmp,m_sShortName);
 
590
 
 
591
        try { m_sName = new char[strlen(tmp)+1]; } catch(...) { m_sName = NULL; }
 
592
        if (m_sName == NULL) NewException((double)(strlen(tmp)+1)*sizeof(char),__FILE__,__LINE__,__PRETTY_FUNCTION__);
 
593
        
 
594
        strcpy(m_sName,tmp);
 
595
        BTOUT;
 
596
}
 
597
 
 
598
 
 
599
void CPlDF::BuildName()
 
600
{
 
601
        BTIN;
 
602
        char tmp[256];
 
603
        CAtomGroup *ag;
 
604
 
 
605
        tmp[0] = 0;
 
606
 
 
607
        strcat(tmp,"[");
 
608
        if (m_bNormal)
 
609
        {
 
610
                ag = (CAtomGroup*)m_oaVectors[0];
 
611
                strcat(tmp,ag->m_sName);
 
612
                if (m_iRefOrSec[0])
 
613
                        strcat(tmp,"o_");
 
614
                                else strcat(tmp,"r_");
 
615
                strcat(tmp,((CAtomGroup*)m_oaVectors[1])->m_sName);
 
616
                if (m_iRefOrSec[1])
 
617
                        strcat(tmp,"o");
 
618
                                else strcat(tmp,"r");
 
619
        } else
 
620
        {
 
621
                ag = (CAtomGroup*)m_oaVectors[0];
 
622
                strcat(tmp,ag->m_sName);
 
623
                if (m_iRefOrSec[0])
 
624
                        strcat(tmp,"o_");
 
625
                                else strcat(tmp,"r_");
 
626
                strcat(tmp,((CAtomGroup*)m_oaVectors[1])->m_sName);
 
627
                if (m_iRefOrSec[1])
 
628
                        strcat(tmp,"o_");
 
629
                                else strcat(tmp,"r_");
 
630
                strcat(tmp,((CAtomGroup*)m_oaVectors[2])->m_sName);
 
631
                if (m_iRefOrSec[2])
 
632
                        strcat(tmp,"o");
 
633
                                else strcat(tmp,"r");
 
634
        }
 
635
        strcat(tmp,"]_");
 
636
        strcat(tmp,((CAtomGroup*)m_oaVectors[3])->m_sName);
 
637
        if (m_iRefOrSec[3])
 
638
                strcat(tmp,"o");
 
639
                        else strcat(tmp,"r");
 
640
 
 
641
        try { m_sShortName = new char[strlen(tmp)+1]; } catch(...) { m_sShortName = NULL; }
 
642
        if (m_sShortName == NULL) NewException((double)(strlen(tmp)+1)*sizeof(char),__FILE__,__LINE__,__PRETTY_FUNCTION__);
 
643
        
 
644
        strcpy(m_sShortName,tmp);
 
645
        if (m_iShowMol != -1)
 
646
                sprintf(tmp,"%s_%s%d_%s_",((CMolecule*)g_oaMolecules[g_iFixMol])->m_sName,((CAtom*)g_oaAtoms[g_iFixRealAtomType[0]])->m_sName,g_iFixAtom[0]+1,((CMolecule*)g_oaMolecules[m_iShowMol])->m_sName);
 
647
                        else sprintf(tmp,"%s_%s%d_",((CMolecule*)g_oaMolecules[g_iFixMol])->m_sName,((CAtom*)g_oaAtoms[g_iFixRealAtomType[0]])->m_sName,g_iFixAtom[0]+1);
 
648
        strcat(tmp,m_sShortName);
 
649
 
 
650
        try { m_sName = new char[strlen(tmp)+1]; } catch(...) { m_sName = NULL; }
 
651
        if (m_sName == NULL) NewException((double)(strlen(tmp)+1)*sizeof(char),__FILE__,__LINE__,__PRETTY_FUNCTION__);
 
652
        
 
653
        strcpy(m_sName,tmp);
 
654
        BTOUT;
 
655
}
 
656
 
 
657
 
 
658
void CLiDF::BuildName()
 
659
{
 
660
        BTIN;
 
661
        char tmp[256];
 
662
        CAtomGroup *ag;
 
663
 
 
664
        tmp[0] = 0;
 
665
 
 
666
        strcat(tmp,"[");
 
667
        if (m_bNormal)
 
668
        {
 
669
                ag = (CAtomGroup*)m_oaVectors[0];
 
670
                strcat(tmp,ag->m_sName);
 
671
                if (m_iRefOrSec[0])
 
672
                        strcat(tmp,"o_");
 
673
                                else strcat(tmp,"r_");
 
674
                strcat(tmp,((CAtomGroup*)m_oaVectors[1])->m_sName);
 
675
                if (m_iRefOrSec[1])
 
676
                        strcat(tmp,"o_");
 
677
                                else strcat(tmp,"r_");
 
678
                strcat(tmp,((CAtomGroup*)m_oaVectors[2])->m_sName);
 
679
                if (m_iRefOrSec[2])
 
680
                        strcat(tmp,"o");
 
681
                                else strcat(tmp,"r");
 
682
        } else
 
683
        {
 
684
                ag = (CAtomGroup*)m_oaVectors[0];
 
685
                strcat(tmp,ag->m_sName);
 
686
                if (m_iRefOrSec[0])
 
687
                        strcat(tmp,"o_");
 
688
                                else strcat(tmp,"r_");
 
689
                strcat(tmp,((CAtomGroup*)m_oaVectors[1])->m_sName);
 
690
                if (m_iRefOrSec[1])
 
691
                        strcat(tmp,"o");
 
692
                                else strcat(tmp,"r");
 
693
        }
 
694
        strcat(tmp,"]_");
 
695
        strcat(tmp,((CAtomGroup*)m_oaVectors[3])->m_sName);
 
696
        if (m_iRefOrSec[3])
 
697
                strcat(tmp,"o");
 
698
                        else strcat(tmp,"r");
 
699
 
 
700
        try { m_sShortName = new char[strlen(tmp)+1]; } catch(...) { m_sShortName = NULL; }
 
701
        if (m_sShortName == NULL) NewException((double)(strlen(tmp)+1)*sizeof(char),__FILE__,__LINE__,__PRETTY_FUNCTION__);
 
702
        
 
703
        strcpy(m_sShortName,tmp);
 
704
        if (m_iShowMol != -1)
 
705
                sprintf(tmp,"%s_%s%d_%s_",((CMolecule*)g_oaMolecules[g_iFixMol])->m_sName,((CAtom*)g_oaAtoms[g_iFixRealAtomType[0]])->m_sName,g_iFixAtom[0]+1,((CMolecule*)g_oaMolecules[m_iShowMol])->m_sName);
 
706
                        else sprintf(tmp,"%s_%s%d_",((CMolecule*)g_oaMolecules[g_iFixMol])->m_sName,((CAtom*)g_oaAtoms[g_iFixRealAtomType[0]])->m_sName,g_iFixAtom[0]+1);
 
707
        strcat(tmp,m_sShortName);
 
708
 
 
709
        try { m_sName = new char[strlen(tmp)+1]; } catch(...) { m_sName = NULL; }
 
710
        if (m_sName == NULL) NewException((double)(strlen(tmp)+1)*sizeof(char),__FILE__,__LINE__,__PRETTY_FUNCTION__);
 
711
        
 
712
        strcpy(m_sName,tmp);
 
713
        BTOUT;
 
714
}
 
715
 
 
716
 
 
717
void CDDF::BuildName()
 
718
{
 
719
        BTIN;
 
720
        int z;
 
721
        char tmp[256];
 
722
        CAtomGroup *ag;
 
723
 
 
724
        tmp[0] = 0;
 
725
        if (m_iDeriv != 0)
 
726
                sprintf(tmp,"deriv%d_",m_iDeriv);
 
727
        for (z=0;z<3;z++)
 
728
        {
 
729
                strcat(tmp,"[");
 
730
                if (m_bOrtho[z])
 
731
                {
 
732
                        ag = (CAtomGroup*)m_oaVectors[z*3];
 
733
                        strcat(tmp,ag->m_sName);
 
734
                        if (m_iRefOrSec[z][0])
 
735
                                strcat(tmp,"o_");
 
736
                                        else strcat(tmp,"r_");
 
737
                        strcat(tmp,((CAtomGroup*)m_oaVectors[z*3+1])->m_sName);
 
738
                        if (m_iRefOrSec[z][1])
 
739
                                strcat(tmp,"o_");
 
740
                                        else strcat(tmp,"r_");
 
741
                        strcat(tmp,((CAtomGroup*)m_oaVectors[z*3+2])->m_sName);
 
742
                        if (m_iRefOrSec[z][2])
 
743
                                strcat(tmp,"o");
 
744
                                        else strcat(tmp,"r");
 
745
                } else
 
746
                {
 
747
                        ag = (CAtomGroup*)m_oaVectors[z*3];
 
748
                        strcat(tmp,ag->m_sName);
 
749
                        if (m_iRefOrSec[z][0])
 
750
                                strcat(tmp,"o_");
 
751
                                        else strcat(tmp,"r_");
 
752
                        strcat(tmp,((CAtomGroup*)m_oaVectors[z*3+1])->m_sName);
 
753
                        if (m_iRefOrSec[z][1])
 
754
                                strcat(tmp,"o");
 
755
                                        else strcat(tmp,"r");
 
756
                }
 
757
                if (z < 2)
 
758
                        strcat(tmp,"]-");
 
759
                                else strcat(tmp,"]");
 
760
        }
 
761
 
 
762
        try { m_sShortName = new char[strlen(tmp)+1]; } catch(...) { m_sShortName = NULL; }
 
763
        if (m_sShortName == NULL) NewException((double)(strlen(tmp)+1)*sizeof(char),__FILE__,__LINE__,__PRETTY_FUNCTION__);
 
764
        
 
765
        strcpy(m_sShortName,tmp);
 
766
        if (m_iShowMol != -1)
 
767
                sprintf(tmp,"%s_%s%d_%s_",((CMolecule*)g_oaMolecules[g_iFixMol])->m_sName,((CAtom*)g_oaAtoms[g_iFixRealAtomType[0]])->m_sName,g_iFixAtom[0]+1,((CMolecule*)g_oaMolecules[m_iShowMol])->m_sName);
 
768
                        else sprintf(tmp,"%s_%s%d_",((CMolecule*)g_oaMolecules[g_iFixMol])->m_sName,((CAtom*)g_oaAtoms[g_iFixRealAtomType[0]])->m_sName,g_iFixAtom[0]+1);
 
769
        strcat(tmp,m_sShortName);
 
770
 
 
771
        try { m_sName = new char[strlen(tmp)+1]; } catch(...) { m_sName = NULL; }
 
772
        if (m_sName == NULL) NewException((double)(strlen(tmp)+1)*sizeof(char),__FILE__,__LINE__,__PRETTY_FUNCTION__);
 
773
        
 
774
        strcpy(m_sName,tmp);
 
775
        BTOUT;
 
776
}
 
777
 
 
778
 
 
779
void CDipDF::BuildName()
 
780
{
 
781
        BTIN;
 
782
        char tmp[256];
 
783
 
 
784
        tmp[0] = 0;
 
785
        if (m_iDeriv != 0)
 
786
                sprintf(tmp,"deriv%d_",m_iDeriv);
 
787
        if (m_iRefOrSec)
 
788
                sprintf(tmp,"%s",((CMolecule*)g_oaMolecules[m_iShowMol])->m_sName);
 
789
                        else sprintf(tmp,"%s",((CMolecule*)g_oaMolecules[g_iFixMol])->m_sName);
 
790
 
 
791
        try { m_sName = new char[strlen(tmp)+1]; } catch(...) { m_sName = NULL; }
 
792
        if (m_sName == NULL) NewException((double)(strlen(tmp)+1)*sizeof(char),__FILE__,__LINE__,__PRETTY_FUNCTION__);
 
793
 
 
794
        strcpy(m_sName,tmp);
 
795
 
 
796
        try { m_sShortName = new char[strlen(tmp)+1]; } catch(...) { m_sShortName = NULL; }
 
797
        if (m_sShortName == NULL) NewException((double)(strlen(tmp)+1)*sizeof(char),__FILE__,__LINE__,__PRETTY_FUNCTION__);
 
798
        
 
799
        strcpy(m_sShortName,tmp);
 
800
        BTOUT;
 
801
}
 
802
 
 
803
 
 
804
void CADF::BuildAtomList(CSingleMolecule *ref, CSingleMolecule *obs, CxIntArray *vec)
 
805
{
 
806
        BXIN;
 
807
        int z, z1t, z1a, z2t, z2a, z3t, z3a, z4t, z4a, z5t, z5a, z6t, z6a;
 
808
        CAtomGroup *g1, *g2, *g3, *g4, *g5, *g6;
 
809
        CxIntArray *a1, *a2, *a3, *a4, *a5, *a6;
 
810
 
 
811
        vec->RemoveAll_KeepSize();
 
812
        for (z=0;z<m_oaVectors.GetSize()/6;z++)
 
813
        {
 
814
                if (m_bOrtho[0])
 
815
                {
 
816
                        g1 = (CAtomGroup*)m_oaVectors[z*6];
 
817
                        g2 = (CAtomGroup*)m_oaVectors[z*6+1];
 
818
                        g3 = (CAtomGroup*)m_oaVectors[z*6+2];
 
819
                        for (z1t=0;z1t<g1->m_baAtomType.GetSize();z1t++)
 
820
                        {
 
821
                                a1 = (CxIntArray*)g1->m_oaAtoms[z1t];
 
822
                                for (z1a=0;z1a<a1->GetSize();z1a++)
 
823
                                {
 
824
                                        for (z2t=0;z2t<g2->m_baAtomType.GetSize();z2t++)
 
825
                                        {
 
826
                                                a2 = (CxIntArray*)g2->m_oaAtoms[z2t];
 
827
                                                for (z2a=0;z2a<a2->GetSize();z2a++)
 
828
                                                {
 
829
                                                        for (z3t=0;z3t<g3->m_baAtomType.GetSize();z3t++)
 
830
                                                        {
 
831
                                                                a3 = (CxIntArray*)g3->m_oaAtoms[z3t];
 
832
                                                                for (z3a=0;z3a<a3->GetSize();z3a++)
 
833
                                                                {
 
834
                                                                        if (m_bOrtho[1])
 
835
                                                                        {
 
836
                                                        /*                      if (m_bSameFoot)
 
837
                                                                                        g4 = g1;
 
838
                                                                                                else */g4 = (CAtomGroup*)m_oaVectors[z*6+3];
 
839
                                                                                g5 = (CAtomGroup*)m_oaVectors[z*6+4];
 
840
                                                                                g6 = (CAtomGroup*)m_oaVectors[z*6+5];
 
841
                                                                                for (z4t=0;z4t<g4->m_baAtomType.GetSize();z4t++)
 
842
                                                                                {
 
843
                                                                /*                      if (m_bSameFoot && (z4t != z1t))
 
844
                                                                                                continue;*/
 
845
                                                                                        a4 = (CxIntArray*)g4->m_oaAtoms[z4t];
 
846
                                                                                        for (z4a=0;z4a<a4->GetSize();z4a++)
 
847
                                                                                        {
 
848
                                                                                /*              if (m_bSameFoot && (z4a != z1a))
 
849
                                                                                                        continue;*/
 
850
                                                                                                for (z5t=0;z5t<g5->m_baAtomType.GetSize();z5t++)
 
851
                                                                                                {
 
852
                                                                                                        a5 = (CxIntArray*)g5->m_oaAtoms[z5t];
 
853
                                                                                                        for (z5a=0;z5a<a5->GetSize();z5a++)
 
854
                                                                                                        {
 
855
                                                                                                                for (z6t=0;z6t<g6->m_baAtomType.GetSize();z6t++)
 
856
                                                                                                                {
 
857
                                                                                                                        a6 = (CxIntArray*)g6->m_oaAtoms[z6t];
 
858
                                                                                                                        for (z6a=0;z6a<a6->GetSize();z6a++)
 
859
                                                                                                                        {
 
860
                                                                                                                                if ((!m_iRefOrSec[0][0]) || (obs == NULL))
 
861
                                                                                                                                        vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g1->m_baAtomType[z1t]])->GetAt(a1->GetAt(z1a)));
 
862
                                                                                                                                                else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g1->m_baAtomType[z1t]])->GetAt(a1->GetAt(z1a)));
 
863
                                                                                                                                if ((!m_iRefOrSec[0][1]) || (obs == NULL))
 
864
                                                                                                                                        vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g2->m_baAtomType[z2t]])->GetAt(a2->GetAt(z2a)));
 
865
                                                                                                                                                else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g2->m_baAtomType[z2t]])->GetAt(a2->GetAt(z2a)));
 
866
                                                                                                                                if ((!m_iRefOrSec[0][2]) || (obs == NULL))
 
867
                                                                                                                                        vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g3->m_baAtomType[z3t]])->GetAt(a3->GetAt(z3a)));
 
868
                                                                                                                                                else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g3->m_baAtomType[z3t]])->GetAt(a3->GetAt(z3a)));
 
869
                                                                                                                                if ((!m_iRefOrSec[1][0]) || (obs == NULL))
 
870
                                                                                                                                        vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g4->m_baAtomType[z4t]])->GetAt(a4->GetAt(z4a)));
 
871
                                                                                                                                                else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g4->m_baAtomType[z4t]])->GetAt(a4->GetAt(z4a)));
 
872
                                                                                                                                if ((!m_iRefOrSec[1][1]) || (obs == NULL))
 
873
                                                                                                                                        vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g5->m_baAtomType[z5t]])->GetAt(a5->GetAt(z5a)));
 
874
                                                                                                                                                else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g5->m_baAtomType[z5t]])->GetAt(a5->GetAt(z5a)));
 
875
                                                                                                                                if ((!m_iRefOrSec[1][2]) || (obs == NULL))
 
876
                                                                                                                                        vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g6->m_baAtomType[z6t]])->GetAt(a6->GetAt(z6a)));
 
877
                                                                                                                                                else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g6->m_baAtomType[z6t]])->GetAt(a6->GetAt(z6a)));
 
878
                                                                                                                        }
 
879
                                                                                                                }
 
880
                                                                                                        }
 
881
                                                                                                }
 
882
                                                                                        }
 
883
                                                                                }
 
884
                                                                        } else
 
885
                                                                        {
 
886
                                                                /*              if (m_bSameFoot)
 
887
                                                                                        g4 = g1;
 
888
                                                                                                else */g4 = (CAtomGroup*)m_oaVectors[z*6+3];
 
889
                                                                                g5 = (CAtomGroup*)m_oaVectors[z*6+4];
 
890
                                                                                for (z4t=0;z4t<g4->m_baAtomType.GetSize();z4t++)
 
891
                                                                                {
 
892
                                                                /*                      if (m_bSameFoot && (z4t != z1t))
 
893
                                                                                                continue;*/
 
894
                                                                                        a4 = (CxIntArray*)g4->m_oaAtoms[z4t];
 
895
                                                                                        for (z4a=0;z4a<a4->GetSize();z4a++)
 
896
                                                                                        {
 
897
                                                                        /*                      if (m_bSameFoot && (z4a != z1a))
 
898
                                                                                                        continue;*/
 
899
                                                                                                for (z5t=0;z5t<g5->m_baAtomType.GetSize();z5t++)
 
900
                                                                                                {
 
901
                                                                                                        a5 = (CxIntArray*)g5->m_oaAtoms[z5t];
 
902
                                                                                                        for (z5a=0;z5a<a5->GetSize();z5a++)
 
903
                                                                                                        {
 
904
                                                                                                                if ((!m_iRefOrSec[0][0]) || (obs == NULL))
 
905
                                                                                                                        vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g1->m_baAtomType[z1t]])->GetAt(a1->GetAt(z1a)));
 
906
                                                                                                                                else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g1->m_baAtomType[z1t]])->GetAt(a1->GetAt(z1a)));
 
907
                                                                                                                if ((!m_iRefOrSec[0][1]) || (obs == NULL))
 
908
                                                                                                                        vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g2->m_baAtomType[z2t]])->GetAt(a2->GetAt(z2a)));
 
909
                                                                                                                                else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g2->m_baAtomType[z2t]])->GetAt(a2->GetAt(z2a)));
 
910
                                                                                                                if ((!m_iRefOrSec[0][2]) || (obs == NULL))
 
911
                                                                                                                        vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g3->m_baAtomType[z3t]])->GetAt(a3->GetAt(z3a)));
 
912
                                                                                                                                else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g3->m_baAtomType[z3t]])->GetAt(a3->GetAt(z3a)));
 
913
                                                                                                                if ((!m_iRefOrSec[1][0]) || (obs == NULL))
 
914
                                                                                                                        vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g4->m_baAtomType[z4t]])->GetAt(a4->GetAt(z4a)));
 
915
                                                                                                                                else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g4->m_baAtomType[z4t]])->GetAt(a4->GetAt(z4a)));
 
916
                                                                                                                if ((!m_iRefOrSec[1][1]) || (obs == NULL))
 
917
                                                                                                                        vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g5->m_baAtomType[z5t]])->GetAt(a5->GetAt(z5a)));
 
918
                                                                                                                                else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g5->m_baAtomType[z5t]])->GetAt(a5->GetAt(z5a)));
 
919
                                                                                                                vec->Add(0);
 
920
                                                                                                        }
 
921
                                                                                                }
 
922
                                                                                        }
 
923
                                                                                }
 
924
                                                                        } // END IF NOT ORTHO[1]
 
925
                                                                }
 
926
                                                        }
 
927
                                                }
 
928
                                        }
 
929
                                }
 
930
                        }
 
931
                } else
 
932
                {
 
933
                        g1 = (CAtomGroup*)m_oaVectors[z*6];
 
934
                        g2 = (CAtomGroup*)m_oaVectors[z*6+1];
 
935
                        for (z1t=0;z1t<g1->m_baAtomType.GetSize();z1t++)
 
936
                        {
 
937
                                a1 = (CxIntArray*)g1->m_oaAtoms[z1t];
 
938
                                for (z1a=0;z1a<a1->GetSize();z1a++)
 
939
                                {
 
940
                                        for (z2t=0;z2t<g2->m_baAtomType.GetSize();z2t++)
 
941
                                        {
 
942
                                                a2 = (CxIntArray*)g2->m_oaAtoms[z2t];
 
943
                                                for (z2a=0;z2a<a2->GetSize();z2a++)
 
944
                                                {
 
945
                                                        if (m_bOrtho[1])
 
946
                                                        {
 
947
                                                /*              if (m_bSameFoot)
 
948
                                                                        g4 = g1;
 
949
                                                                                else */g4 = (CAtomGroup*)m_oaVectors[z*6+3];
 
950
                                                                g5 = (CAtomGroup*)m_oaVectors[z*6+4];
 
951
                                                                g6 = (CAtomGroup*)m_oaVectors[z*6+5];
 
952
                                                                for (z4t=0;z4t<g4->m_baAtomType.GetSize();z4t++)
 
953
                                                                {
 
954
                                                /*                      if (m_bSameFoot && (z4t != z1t))
 
955
                                                                                continue;*/
 
956
                                                                        a4 = (CxIntArray*)g4->m_oaAtoms[z4t];
 
957
                                                                        for (z4a=0;z4a<a4->GetSize();z4a++)
 
958
                                                                        {
 
959
                                                        /*                      if (m_bSameFoot && (z4a != z1a))
 
960
                                                                                        continue;*/
 
961
                                                                                for (z5t=0;z5t<g5->m_baAtomType.GetSize();z5t++)
 
962
                                                                                {
 
963
                                                                                        a5 = (CxIntArray*)g5->m_oaAtoms[z5t];
 
964
                                                                                        for (z5a=0;z5a<a5->GetSize();z5a++)
 
965
                                                                                        {
 
966
                                                                                                for (z6t=0;z6t<g6->m_baAtomType.GetSize();z6t++)
 
967
                                                                                                {
 
968
                                                                                                        a6 = (CxIntArray*)g6->m_oaAtoms[z6t];
 
969
                                                                                                        for (z6a=0;z6a<a6->GetSize();z6a++)
 
970
                                                                                                        {
 
971
                                                                                                                if ((!m_iRefOrSec[0][0]) || (obs == NULL))
 
972
                                                                                                                        vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g1->m_baAtomType[z1t]])->GetAt(a1->GetAt(z1a)));
 
973
                                                                                                                                else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g1->m_baAtomType[z1t]])->GetAt(a1->GetAt(z1a)));
 
974
                                                                                                                if ((!m_iRefOrSec[0][1]) || (obs == NULL))
 
975
                                                                                                                        vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g2->m_baAtomType[z2t]])->GetAt(a2->GetAt(z2a)));
 
976
                                                                                                                                else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g2->m_baAtomType[z2t]])->GetAt(a2->GetAt(z2a)));
 
977
                                                                                                                vec->Add(0);
 
978
                                                                                                                if ((!m_iRefOrSec[1][0]) || (obs == NULL))
 
979
                                                                                                                        vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g4->m_baAtomType[z4t]])->GetAt(a4->GetAt(z4a)));
 
980
                                                                                                                                else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g4->m_baAtomType[z4t]])->GetAt(a4->GetAt(z4a)));
 
981
                                                                                                                if ((!m_iRefOrSec[1][1]) || (obs == NULL))
 
982
                                                                                                                        vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g5->m_baAtomType[z5t]])->GetAt(a5->GetAt(z5a)));
 
983
                                                                                                                                else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g5->m_baAtomType[z5t]])->GetAt(a5->GetAt(z5a)));
 
984
                                                                                                                if ((!m_iRefOrSec[1][2]) || (obs == NULL))
 
985
                                                                                                                        vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g6->m_baAtomType[z6t]])->GetAt(a6->GetAt(z6a)));
 
986
                                                                                                                                else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g6->m_baAtomType[z6t]])->GetAt(a6->GetAt(z6a)));
 
987
                                                                                                        }
 
988
                                                                                                }
 
989
                                                                                        }
 
990
                                                                                }
 
991
                                                                        }
 
992
                                                                }
 
993
                                                        } else
 
994
                                                        {
 
995
                                                /*              if (m_bSameFoot)
 
996
                                                                        g4 = g1;
 
997
                                                                                else */g4 = (CAtomGroup*)m_oaVectors[z*6+3];
 
998
                                                                g5 = (CAtomGroup*)m_oaVectors[z*6+4];
 
999
                                                                for (z4t=0;z4t<g4->m_baAtomType.GetSize();z4t++)
 
1000
                                                                {
 
1001
                                                        /*              if (m_bSameFoot && (z4t != z1t))
 
1002
                                                                                continue;*/
 
1003
                                                                        a4 = (CxIntArray*)g4->m_oaAtoms[z4t];
 
1004
                                                                        for (z4a=0;z4a<a4->GetSize();z4a++)
 
1005
                                                                        {
 
1006
                                                                /*              if (m_bSameFoot && (z4a != z1a))
 
1007
                                                                                        continue;*/
 
1008
                                                                                for (z5t=0;z5t<g5->m_baAtomType.GetSize();z5t++)
 
1009
                                                                                {
 
1010
                                                                                        a5 = (CxIntArray*)g5->m_oaAtoms[z5t];
 
1011
                                                                                        for (z5a=0;z5a<a5->GetSize();z5a++)
 
1012
                                                                                        {
 
1013
                                                                                                if ((!m_iRefOrSec[0][0]) || (obs == NULL))
 
1014
                                                                                                        vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g1->m_baAtomType[z1t]])->GetAt(a1->GetAt(z1a)));
 
1015
                                                                                                                else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g1->m_baAtomType[z1t]])->GetAt(a1->GetAt(z1a)));
 
1016
                                                                                                if ((!m_iRefOrSec[0][1]) || (obs == NULL))
 
1017
                                                                                                        vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g2->m_baAtomType[z2t]])->GetAt(a2->GetAt(z2a)));
 
1018
                                                                                                                else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g2->m_baAtomType[z2t]])->GetAt(a2->GetAt(z2a)));
 
1019
                                                                                                vec->Add(0);
 
1020
                                                                                                if ((!m_iRefOrSec[1][0]) || (obs == NULL))
 
1021
                                                                                                        vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g4->m_baAtomType[z4t]])->GetAt(a4->GetAt(z4a)));
 
1022
                                                                                                                else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g4->m_baAtomType[z4t]])->GetAt(a4->GetAt(z4a)));
 
1023
                                                                                                if ((!m_iRefOrSec[1][1]) || (obs == NULL))
 
1024
                                                                                                        vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g5->m_baAtomType[z5t]])->GetAt(a5->GetAt(z5a)));
 
1025
                                                                                                                else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g5->m_baAtomType[z5t]])->GetAt(a5->GetAt(z5a)));
 
1026
                                                                                                vec->Add(0);
 
1027
                                                                                        }
 
1028
                                                                                }
 
1029
                                                                        }
 
1030
                                                                }
 
1031
                                                        } // END IF NOT ORTHO[1]
 
1032
                                                }
 
1033
                                        }
 
1034
                                }
 
1035
                        }
 
1036
                }
 
1037
        }
 
1038
        BXOUT;
 
1039
}
 
1040
 
 
1041
 
 
1042
/* Mega abartig !!!! */
 
1043
void CDDF::BuildAtomList(CSingleMolecule *ref, CSingleMolecule *obs, CxIntArray *vec)
 
1044
{
 
1045
        BXIN;
 
1046
        int z, z1t, z1a, z2t, z2a, z3t, z3a, z4t, z4a, z5t, z5a, z6t, z6a, z7t, z7a, z8t, z8a, z9t, z9a;
 
1047
        CAtomGroup *g1, *g2, *g3, *g4, *g5, *g6, *g7, *g8, *g9;
 
1048
        CxIntArray *a1, *a2, *a3, *a4, *a5, *a6, *a7, *a8, *a9;
 
1049
 
 
1050
        vec->RemoveAll_KeepSize();
 
1051
        for (z=0;z<m_oaVectors.GetSize()/9;z++)
 
1052
        {
 
1053
                if (m_bOrtho[0])
 
1054
                {
 
1055
                        g1 = (CAtomGroup*)m_oaVectors[z*9];
 
1056
                        g2 = (CAtomGroup*)m_oaVectors[z*9+1];
 
1057
                        g3 = (CAtomGroup*)m_oaVectors[z*9+2];
 
1058
                        for (z1t=0;z1t<g1->m_baAtomType.GetSize();z1t++)
 
1059
                        {
 
1060
                                a1 = (CxIntArray*)g1->m_oaAtoms[z1t];
 
1061
                                for (z1a=0;z1a<a1->GetSize();z1a++)
 
1062
                                {
 
1063
                                        for (z2t=0;z2t<g2->m_baAtomType.GetSize();z2t++)
 
1064
                                        {
 
1065
                                                a2 = (CxIntArray*)g2->m_oaAtoms[z2t];
 
1066
                                                for (z2a=0;z2a<a2->GetSize();z2a++)
 
1067
                                                {
 
1068
                                                        for (z3t=0;z3t<g3->m_baAtomType.GetSize();z3t++)
 
1069
                                                        {
 
1070
                                                                a3 = (CxIntArray*)g3->m_oaAtoms[z3t];
 
1071
                                                                for (z3a=0;z3a<a3->GetSize();z3a++)
 
1072
                                                                {
 
1073
                                                                        if (m_bOrtho[1])
 
1074
                                                                        {
 
1075
                                                                                g4 = (CAtomGroup*)m_oaVectors[z*9+3];
 
1076
                                                                                g5 = (CAtomGroup*)m_oaVectors[z*9+4];
 
1077
                                                                                g6 = (CAtomGroup*)m_oaVectors[z*9+5];
 
1078
                                                                                for (z4t=0;z4t<g4->m_baAtomType.GetSize();z4t++)
 
1079
                                                                                {
 
1080
                                                                                        a4 = (CxIntArray*)g4->m_oaAtoms[z4t];
 
1081
                                                                                        for (z4a=0;z4a<a4->GetSize();z4a++)
 
1082
                                                                                        {
 
1083
                                                                                                for (z5t=0;z5t<g5->m_baAtomType.GetSize();z5t++)
 
1084
                                                                                                {
 
1085
                                                                                                        a5 = (CxIntArray*)g5->m_oaAtoms[z5t];
 
1086
                                                                                                        for (z5a=0;z5a<a5->GetSize();z5a++)
 
1087
                                                                                                        {
 
1088
                                                                                                                for (z6t=0;z6t<g6->m_baAtomType.GetSize();z6t++)
 
1089
                                                                                                                {
 
1090
                                                                                                                        a6 = (CxIntArray*)g6->m_oaAtoms[z6t];
 
1091
                                                                                                                        for (z6a=0;z6a<a6->GetSize();z6a++)
 
1092
                                                                                                                        {
 
1093
                                                                                                                                if (m_bOrtho[2])
 
1094
                                                                                                                                {
 
1095
                                                                                                                                        g7 = (CAtomGroup*)m_oaVectors[z*9+6];
 
1096
                                                                                                                                        g8 = (CAtomGroup*)m_oaVectors[z*9+7];
 
1097
                                                                                                                                        g9 = (CAtomGroup*)m_oaVectors[z*9+8];
 
1098
                                                                                                                                        for (z7t=0;z7t<g7->m_baAtomType.GetSize();z7t++)
 
1099
                                                                                                                                        {
 
1100
                                                                                                                                                a7 = (CxIntArray*)g7->m_oaAtoms[z7t];
 
1101
                                                                                                                                                for (z7a=0;z7a<a7->GetSize();z7a++)
 
1102
                                                                                                                                                {
 
1103
                                                                                                                                                        for (z8t=0;z8t<g8->m_baAtomType.GetSize();z8t++)
 
1104
                                                                                                                                                        {
 
1105
                                                                                                                                                                a8 = (CxIntArray*)g8->m_oaAtoms[z8t];
 
1106
                                                                                                                                                                for (z8a=0;z8a<a8->GetSize();z8a++)
 
1107
                                                                                                                                                                {
 
1108
                                                                                                                                                                        for (z9t=0;z9t<g9->m_baAtomType.GetSize();z9t++)
 
1109
                                                                                                                                                                        {
 
1110
                                                                                                                                                                                a9 = (CxIntArray*)g9->m_oaAtoms[z9t];
 
1111
                                                                                                                                                                                for (z9a=0;z9a<a9->GetSize();z9a++)
 
1112
                                                                                                                                                                                {
 
1113
                                                                                                                                                                                        if ((!m_iRefOrSec[0][0]) || (obs == NULL))
 
1114
                                                                                                                                                                                                vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g1->m_baAtomType[z1t]])->GetAt(a1->GetAt(z1a)));
 
1115
                                                                                                                                                                                                        else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g1->m_baAtomType[z1t]])->GetAt(a1->GetAt(z1a)));
 
1116
                                                                                                                                                                                        if ((!m_iRefOrSec[0][1]) || (obs == NULL))
 
1117
                                                                                                                                                                                                vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g2->m_baAtomType[z2t]])->GetAt(a2->GetAt(z2a)));
 
1118
                                                                                                                                                                                                        else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g2->m_baAtomType[z2t]])->GetAt(a2->GetAt(z2a)));
 
1119
                                                                                                                                                                                        if ((!m_iRefOrSec[0][2]) || (obs == NULL))
 
1120
                                                                                                                                                                                                vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g3->m_baAtomType[z3t]])->GetAt(a3->GetAt(z3a)));
 
1121
                                                                                                                                                                                                        else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g3->m_baAtomType[z3t]])->GetAt(a3->GetAt(z3a)));
 
1122
                                                                                                                                                                                        if ((!m_iRefOrSec[1][0]) || (obs == NULL))
 
1123
                                                                                                                                                                                                vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g4->m_baAtomType[z4t]])->GetAt(a4->GetAt(z4a)));
 
1124
                                                                                                                                                                                                        else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g4->m_baAtomType[z4t]])->GetAt(a4->GetAt(z4a)));
 
1125
                                                                                                                                                                                        if ((!m_iRefOrSec[1][1]) || (obs == NULL))
 
1126
                                                                                                                                                                                                vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g5->m_baAtomType[z5t]])->GetAt(a5->GetAt(z5a)));
 
1127
                                                                                                                                                                                                        else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g5->m_baAtomType[z5t]])->GetAt(a5->GetAt(z5a)));
 
1128
                                                                                                                                                                                        if ((!m_iRefOrSec[1][2]) || (obs == NULL))
 
1129
                                                                                                                                                                                                vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g6->m_baAtomType[z6t]])->GetAt(a6->GetAt(z6a)));
 
1130
                                                                                                                                                                                                        else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g6->m_baAtomType[z6t]])->GetAt(a6->GetAt(z6a)));
 
1131
                                                                                                                                                                                        if ((!m_iRefOrSec[2][0]) || (obs == NULL))
 
1132
                                                                                                                                                                                                vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g7->m_baAtomType[z7t]])->GetAt(a7->GetAt(z7a)));
 
1133
                                                                                                                                                                                                        else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g7->m_baAtomType[z7t]])->GetAt(a7->GetAt(z7a)));
 
1134
                                                                                                                                                                                        if ((!m_iRefOrSec[2][1]) || (obs == NULL))
 
1135
                                                                                                                                                                                                vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g8->m_baAtomType[z8t]])->GetAt(a8->GetAt(z8a)));
 
1136
                                                                                                                                                                                                        else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g8->m_baAtomType[z8t]])->GetAt(a8->GetAt(z8a)));
 
1137
                                                                                                                                                                                        if ((!m_iRefOrSec[2][2]) || (obs == NULL))
 
1138
                                                                                                                                                                                                vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g9->m_baAtomType[z9t]])->GetAt(a9->GetAt(z9a)));
 
1139
                                                                                                                                                                                                        else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g9->m_baAtomType[z9t]])->GetAt(a9->GetAt(z9a)));
 
1140
                                                                                                                                                                                }
 
1141
                                                                                                                                                                        }
 
1142
                                                                                                                                                                }
 
1143
                                                                                                                                                        }
 
1144
                                                                                                                                                }
 
1145
                                                                                                                                        }
 
1146
                                                                                                                                } else // IF NOT ORTHO[2]
 
1147
                                                                                                                                {
 
1148
                                                                                                                                        g7 = (CAtomGroup*)m_oaVectors[z*9+6];
 
1149
                                                                                                                                        g8 = (CAtomGroup*)m_oaVectors[z*9+7];
 
1150
                                                                                                                                        for (z7t=0;z7t<g7->m_baAtomType.GetSize();z7t++)
 
1151
                                                                                                                                        {
 
1152
                                                                                                                                                a7 = (CxIntArray*)g7->m_oaAtoms[z7t];
 
1153
                                                                                                                                                for (z7a=0;z7a<a7->GetSize();z7a++)
 
1154
                                                                                                                                                {
 
1155
                                                                                                                                                        for (z8t=0;z8t<g8->m_baAtomType.GetSize();z8t++)
 
1156
                                                                                                                                                        {
 
1157
                                                                                                                                                                a8 = (CxIntArray*)g8->m_oaAtoms[z8t];
 
1158
                                                                                                                                                                for (z8a=0;z8a<a8->GetSize();z8a++)
 
1159
                                                                                                                                                                {
 
1160
                                                                                                                                                                        if ((!m_iRefOrSec[0][0]) || (obs == NULL))
 
1161
                                                                                                                                                                                vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g1->m_baAtomType[z1t]])->GetAt(a1->GetAt(z1a)));
 
1162
                                                                                                                                                                                        else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g1->m_baAtomType[z1t]])->GetAt(a1->GetAt(z1a)));
 
1163
                                                                                                                                                                        if ((!m_iRefOrSec[0][1]) || (obs == NULL))
 
1164
                                                                                                                                                                                vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g2->m_baAtomType[z2t]])->GetAt(a2->GetAt(z2a)));
 
1165
                                                                                                                                                                                        else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g2->m_baAtomType[z2t]])->GetAt(a2->GetAt(z2a)));
 
1166
                                                                                                                                                                        if ((!m_iRefOrSec[0][2]) || (obs == NULL))
 
1167
                                                                                                                                                                                vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g3->m_baAtomType[z3t]])->GetAt(a3->GetAt(z3a)));
 
1168
                                                                                                                                                                                        else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g3->m_baAtomType[z3t]])->GetAt(a3->GetAt(z3a)));
 
1169
                                                                                                                                                                        if ((!m_iRefOrSec[1][0]) || (obs == NULL))
 
1170
                                                                                                                                                                                vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g4->m_baAtomType[z4t]])->GetAt(a4->GetAt(z4a)));
 
1171
                                                                                                                                                                                        else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g4->m_baAtomType[z4t]])->GetAt(a4->GetAt(z4a)));
 
1172
                                                                                                                                                                        if ((!m_iRefOrSec[1][1]) || (obs == NULL))
 
1173
                                                                                                                                                                                vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g5->m_baAtomType[z5t]])->GetAt(a5->GetAt(z5a)));
 
1174
                                                                                                                                                                                        else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g5->m_baAtomType[z5t]])->GetAt(a5->GetAt(z5a)));
 
1175
                                                                                                                                                                        if ((!m_iRefOrSec[1][2]) || (obs == NULL))
 
1176
                                                                                                                                                                                vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g6->m_baAtomType[z6t]])->GetAt(a6->GetAt(z6a)));
 
1177
                                                                                                                                                                                        else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g6->m_baAtomType[z6t]])->GetAt(a6->GetAt(z6a)));
 
1178
                                                                                                                                                                        if ((!m_iRefOrSec[2][0]) || (obs == NULL))
 
1179
                                                                                                                                                                                vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g7->m_baAtomType[z7t]])->GetAt(a7->GetAt(z7a)));
 
1180
                                                                                                                                                                                        else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g7->m_baAtomType[z7t]])->GetAt(a7->GetAt(z7a)));
 
1181
                                                                                                                                                                        if ((!m_iRefOrSec[2][1]) || (obs == NULL))
 
1182
                                                                                                                                                                                vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g8->m_baAtomType[z8t]])->GetAt(a8->GetAt(z8a)));
 
1183
                                                                                                                                                                                        else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g8->m_baAtomType[z8t]])->GetAt(a8->GetAt(z8a)));
 
1184
                                                                                                                                                                        vec->Add(0);
 
1185
                                                                                                                                                                }
 
1186
                                                                                                                                                        }
 
1187
                                                                                                                                                }
 
1188
                                                                                                                                        }
 
1189
                                                                                                                                } // END IF NOT ORTHO[2]
 
1190
                                                                                                                        }
 
1191
                                                                                                                }
 
1192
                                                                                                        }
 
1193
                                                                                                }
 
1194
                                                                                        }
 
1195
                                                                                }
 
1196
                                                                        } else // IF NOT ORTHO[1]
 
1197
                                                                        {
 
1198
                                                                                g4 = (CAtomGroup*)m_oaVectors[z*9+3];
 
1199
                                                                                g5 = (CAtomGroup*)m_oaVectors[z*9+4];
 
1200
                                                                                for (z4t=0;z4t<g4->m_baAtomType.GetSize();z4t++)
 
1201
                                                                                {
 
1202
                                                                                        a4 = (CxIntArray*)g4->m_oaAtoms[z4t];
 
1203
                                                                                        for (z4a=0;z4a<a4->GetSize();z4a++)
 
1204
                                                                                        {
 
1205
                                                                                                for (z5t=0;z5t<g5->m_baAtomType.GetSize();z5t++)
 
1206
                                                                                                {
 
1207
                                                                                                        a5 = (CxIntArray*)g5->m_oaAtoms[z5t];
 
1208
                                                                                                        for (z5a=0;z5a<a5->GetSize();z5a++)
 
1209
                                                                                                        {
 
1210
                                                                                                                if (m_bOrtho[2])
 
1211
                                                                                                                {
 
1212
                                                                                                                        g7 = (CAtomGroup*)m_oaVectors[z*9+6];
 
1213
                                                                                                                        g8 = (CAtomGroup*)m_oaVectors[z*9+7];
 
1214
                                                                                                                        g9 = (CAtomGroup*)m_oaVectors[z*9+8];
 
1215
                                                                                                                        for (z7t=0;z7t<g7->m_baAtomType.GetSize();z7t++)
 
1216
                                                                                                                        {
 
1217
                                                                                                                                a7 = (CxIntArray*)g7->m_oaAtoms[z7t];
 
1218
                                                                                                                                for (z7a=0;z7a<a7->GetSize();z7a++)
 
1219
                                                                                                                                {
 
1220
                                                                                                                                        for (z8t=0;z8t<g8->m_baAtomType.GetSize();z8t++)
 
1221
                                                                                                                                        {
 
1222
                                                                                                                                                a8 = (CxIntArray*)g8->m_oaAtoms[z8t];
 
1223
                                                                                                                                                for (z8a=0;z8a<a8->GetSize();z8a++)
 
1224
                                                                                                                                                {
 
1225
                                                                                                                                                        for (z9t=0;z9t<g9->m_baAtomType.GetSize();z9t++)
 
1226
                                                                                                                                                        {
 
1227
                                                                                                                                                                a9 = (CxIntArray*)g9->m_oaAtoms[z9t];
 
1228
                                                                                                                                                                for (z9a=0;z9a<a9->GetSize();z9a++)
 
1229
                                                                                                                                                                {
 
1230
                                                                                                                                                                        if ((!m_iRefOrSec[0][0]) || (obs == NULL))
 
1231
                                                                                                                                                                                vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g1->m_baAtomType[z1t]])->GetAt(a1->GetAt(z1a)));
 
1232
                                                                                                                                                                                        else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g1->m_baAtomType[z1t]])->GetAt(a1->GetAt(z1a)));
 
1233
                                                                                                                                                                        if ((!m_iRefOrSec[0][1]) || (obs == NULL))
 
1234
                                                                                                                                                                                vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g2->m_baAtomType[z2t]])->GetAt(a2->GetAt(z2a)));
 
1235
                                                                                                                                                                                        else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g2->m_baAtomType[z2t]])->GetAt(a2->GetAt(z2a)));
 
1236
                                                                                                                                                                        if ((!m_iRefOrSec[0][2]) || (obs == NULL))
 
1237
                                                                                                                                                                                vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g3->m_baAtomType[z3t]])->GetAt(a3->GetAt(z3a)));
 
1238
                                                                                                                                                                                        else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g3->m_baAtomType[z3t]])->GetAt(a3->GetAt(z3a)));
 
1239
                                                                                                                                                                        if ((!m_iRefOrSec[1][0]) || (obs == NULL))
 
1240
                                                                                                                                                                                vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g4->m_baAtomType[z4t]])->GetAt(a4->GetAt(z4a)));
 
1241
                                                                                                                                                                                        else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g4->m_baAtomType[z4t]])->GetAt(a4->GetAt(z4a)));
 
1242
                                                                                                                                                                        if ((!m_iRefOrSec[1][1]) || (obs == NULL))
 
1243
                                                                                                                                                                                vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g5->m_baAtomType[z5t]])->GetAt(a5->GetAt(z5a)));
 
1244
                                                                                                                                                                                        else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g5->m_baAtomType[z5t]])->GetAt(a5->GetAt(z5a)));
 
1245
                                                                                                                                                                        vec->Add(0);
 
1246
                                                                                                                                                                        if ((!m_iRefOrSec[2][0]) || (obs == NULL))
 
1247
                                                                                                                                                                                vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g7->m_baAtomType[z7t]])->GetAt(a7->GetAt(z7a)));
 
1248
                                                                                                                                                                                        else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g7->m_baAtomType[z7t]])->GetAt(a7->GetAt(z7a)));
 
1249
                                                                                                                                                                        if ((!m_iRefOrSec[2][1]) || (obs == NULL))
 
1250
                                                                                                                                                                                vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g8->m_baAtomType[z8t]])->GetAt(a8->GetAt(z8a)));
 
1251
                                                                                                                                                                                        else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g8->m_baAtomType[z8t]])->GetAt(a8->GetAt(z8a)));
 
1252
                                                                                                                                                                        if ((!m_iRefOrSec[2][2]) || (obs == NULL))
 
1253
                                                                                                                                                                                vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g9->m_baAtomType[z9t]])->GetAt(a9->GetAt(z9a)));
 
1254
                                                                                                                                                                                        else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g9->m_baAtomType[z9t]])->GetAt(a9->GetAt(z9a)));
 
1255
                                                                                                                                                                }
 
1256
                                                                                                                                                        }
 
1257
                                                                                                                                                }
 
1258
                                                                                                                                        }
 
1259
                                                                                                                                }
 
1260
                                                                                                                        }
 
1261
                                                                                                                } else // IF NOT ORTHO[2]
 
1262
                                                                                                                {
 
1263
                                                                                                                        g7 = (CAtomGroup*)m_oaVectors[z*9+6];
 
1264
                                                                                                                        g8 = (CAtomGroup*)m_oaVectors[z*9+7];
 
1265
                                                                                                                        for (z7t=0;z7t<g7->m_baAtomType.GetSize();z7t++)
 
1266
                                                                                                                        {
 
1267
                                                                                                                                a7 = (CxIntArray*)g7->m_oaAtoms[z7t];
 
1268
                                                                                                                                for (z7a=0;z7a<a7->GetSize();z7a++)
 
1269
                                                                                                                                {
 
1270
                                                                                                                                        for (z8t=0;z8t<g8->m_baAtomType.GetSize();z8t++)
 
1271
                                                                                                                                        {
 
1272
                                                                                                                                                a8 = (CxIntArray*)g8->m_oaAtoms[z8t];
 
1273
                                                                                                                                                for (z8a=0;z8a<a8->GetSize();z8a++)
 
1274
                                                                                                                                                {
 
1275
                                                                                                                                                        if ((!m_iRefOrSec[0][0]) || (obs == NULL))
 
1276
                                                                                                                                                                vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g1->m_baAtomType[z1t]])->GetAt(a1->GetAt(z1a)));
 
1277
                                                                                                                                                                        else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g1->m_baAtomType[z1t]])->GetAt(a1->GetAt(z1a)));
 
1278
                                                                                                                                                        if ((!m_iRefOrSec[0][1]) || (obs == NULL))
 
1279
                                                                                                                                                                vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g2->m_baAtomType[z2t]])->GetAt(a2->GetAt(z2a)));
 
1280
                                                                                                                                                                        else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g2->m_baAtomType[z2t]])->GetAt(a2->GetAt(z2a)));
 
1281
                                                                                                                                                        if ((!m_iRefOrSec[0][2]) || (obs == NULL))
 
1282
                                                                                                                                                                vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g3->m_baAtomType[z3t]])->GetAt(a3->GetAt(z3a)));
 
1283
                                                                                                                                                                        else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g3->m_baAtomType[z3t]])->GetAt(a3->GetAt(z3a)));
 
1284
                                                                                                                                                        if ((!m_iRefOrSec[1][0]) || (obs == NULL))
 
1285
                                                                                                                                                                vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g4->m_baAtomType[z4t]])->GetAt(a4->GetAt(z4a)));
 
1286
                                                                                                                                                                        else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g4->m_baAtomType[z4t]])->GetAt(a4->GetAt(z4a)));
 
1287
                                                                                                                                                        if ((!m_iRefOrSec[1][1]) || (obs == NULL))
 
1288
                                                                                                                                                                vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g5->m_baAtomType[z5t]])->GetAt(a5->GetAt(z5a)));
 
1289
                                                                                                                                                                        else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g5->m_baAtomType[z5t]])->GetAt(a5->GetAt(z5a)));
 
1290
                                                                                                                                                        vec->Add(0);
 
1291
                                                                                                                                                        if ((!m_iRefOrSec[2][0]) || (obs == NULL))
 
1292
                                                                                                                                                                vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g7->m_baAtomType[z7t]])->GetAt(a7->GetAt(z7a)));
 
1293
                                                                                                                                                                        else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g7->m_baAtomType[z7t]])->GetAt(a7->GetAt(z7a)));
 
1294
                                                                                                                                                        if ((!m_iRefOrSec[2][1]) || (obs == NULL))
 
1295
                                                                                                                                                                vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g8->m_baAtomType[z8t]])->GetAt(a8->GetAt(z8a)));
 
1296
                                                                                                                                                                        else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g8->m_baAtomType[z8t]])->GetAt(a8->GetAt(z8a)));
 
1297
                                                                                                                                                        vec->Add(0);
 
1298
                                                                                                                                                }
 
1299
                                                                                                                                        }
 
1300
                                                                                                                                }
 
1301
                                                                                                                        }
 
1302
                                                                                                                } // END IF NOT ORTHO[2]
 
1303
                                                                                                        }
 
1304
                                                                                                }
 
1305
                                                                                        }
 
1306
                                                                                }
 
1307
                                                                        } // END IF NOT ORTHO[1]
 
1308
                                                                }
 
1309
                                                        }
 
1310
                                                }
 
1311
                                        }
 
1312
                                }
 
1313
                        }
 
1314
                } else // IF NOT ORTHO[0]
 
1315
                {
 
1316
                        g1 = (CAtomGroup*)m_oaVectors[z*9];
 
1317
                        g2 = (CAtomGroup*)m_oaVectors[z*9+1];
 
1318
                        for (z1t=0;z1t<g1->m_baAtomType.GetSize();z1t++)
 
1319
                        {
 
1320
                                a1 = (CxIntArray*)g1->m_oaAtoms[z1t];
 
1321
                                for (z1a=0;z1a<a1->GetSize();z1a++)
 
1322
                                {
 
1323
                                        for (z2t=0;z2t<g2->m_baAtomType.GetSize();z2t++)
 
1324
                                        {
 
1325
                                                a2 = (CxIntArray*)g2->m_oaAtoms[z2t];
 
1326
                                                for (z2a=0;z2a<a2->GetSize();z2a++)
 
1327
                                                {
 
1328
                                                        if (m_bOrtho[1])
 
1329
                                                        {
 
1330
                                                                g4 = (CAtomGroup*)m_oaVectors[z*9+3];
 
1331
                                                                g5 = (CAtomGroup*)m_oaVectors[z*9+4];
 
1332
                                                                g6 = (CAtomGroup*)m_oaVectors[z*9+5];
 
1333
                                                                for (z4t=0;z4t<g4->m_baAtomType.GetSize();z4t++)
 
1334
                                                                {
 
1335
                                                                        a4 = (CxIntArray*)g4->m_oaAtoms[z4t];
 
1336
                                                                        for (z4a=0;z4a<a4->GetSize();z4a++)
 
1337
                                                                        {
 
1338
                                                                                for (z5t=0;z5t<g5->m_baAtomType.GetSize();z5t++)
 
1339
                                                                                {
 
1340
                                                                                        a5 = (CxIntArray*)g5->m_oaAtoms[z5t];
 
1341
                                                                                        for (z5a=0;z5a<a5->GetSize();z5a++)
 
1342
                                                                                        {
 
1343
                                                                                                for (z6t=0;z6t<g6->m_baAtomType.GetSize();z6t++)
 
1344
                                                                                                {
 
1345
                                                                                                        a6 = (CxIntArray*)g6->m_oaAtoms[z6t];
 
1346
                                                                                                        for (z6a=0;z6a<a6->GetSize();z6a++)
 
1347
                                                                                                        {
 
1348
                                                                                                                if (m_bOrtho[2])
 
1349
                                                                                                                {
 
1350
                                                                                                                        g7 = (CAtomGroup*)m_oaVectors[z*9+6];
 
1351
                                                                                                                        g8 = (CAtomGroup*)m_oaVectors[z*9+7];
 
1352
                                                                                                                        g9 = (CAtomGroup*)m_oaVectors[z*9+8];
 
1353
                                                                                                                        for (z7t=0;z7t<g7->m_baAtomType.GetSize();z7t++)
 
1354
                                                                                                                        {
 
1355
                                                                                                                                a7 = (CxIntArray*)g7->m_oaAtoms[z7t];
 
1356
                                                                                                                                for (z7a=0;z7a<a7->GetSize();z7a++)
 
1357
                                                                                                                                {
 
1358
                                                                                                                                        for (z8t=0;z8t<g8->m_baAtomType.GetSize();z8t++)
 
1359
                                                                                                                                        {
 
1360
                                                                                                                                                a8 = (CxIntArray*)g8->m_oaAtoms[z8t];
 
1361
                                                                                                                                                for (z8a=0;z8a<a8->GetSize();z8a++)
 
1362
                                                                                                                                                {
 
1363
                                                                                                                                                        for (z9t=0;z9t<g9->m_baAtomType.GetSize();z9t++)
 
1364
                                                                                                                                                        {
 
1365
                                                                                                                                                                a9 = (CxIntArray*)g9->m_oaAtoms[z9t];
 
1366
                                                                                                                                                                for (z9a=0;z9a<a9->GetSize();z9a++)
 
1367
                                                                                                                                                                {
 
1368
                                                                                                                                                                        if ((!m_iRefOrSec[0][0]) || (obs == NULL))
 
1369
                                                                                                                                                                                vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g1->m_baAtomType[z1t]])->GetAt(a1->GetAt(z1a)));
 
1370
                                                                                                                                                                                        else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g1->m_baAtomType[z1t]])->GetAt(a1->GetAt(z1a)));
 
1371
                                                                                                                                                                        if ((!m_iRefOrSec[0][1]) || (obs == NULL))
 
1372
                                                                                                                                                                                vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g2->m_baAtomType[z2t]])->GetAt(a2->GetAt(z2a)));
 
1373
                                                                                                                                                                                        else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g2->m_baAtomType[z2t]])->GetAt(a2->GetAt(z2a)));
 
1374
                                                                                                                                                                        vec->Add(0);
 
1375
                                                                                                                                                                        if ((!m_iRefOrSec[1][0]) || (obs == NULL))
 
1376
                                                                                                                                                                                vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g4->m_baAtomType[z4t]])->GetAt(a4->GetAt(z4a)));
 
1377
                                                                                                                                                                                        else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g4->m_baAtomType[z4t]])->GetAt(a4->GetAt(z4a)));
 
1378
                                                                                                                                                                        if ((!m_iRefOrSec[1][1]) || (obs == NULL))
 
1379
                                                                                                                                                                                vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g5->m_baAtomType[z5t]])->GetAt(a5->GetAt(z5a)));
 
1380
                                                                                                                                                                                        else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g5->m_baAtomType[z5t]])->GetAt(a5->GetAt(z5a)));
 
1381
                                                                                                                                                                        if ((!m_iRefOrSec[1][2]) || (obs == NULL))
 
1382
                                                                                                                                                                                vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g6->m_baAtomType[z6t]])->GetAt(a6->GetAt(z6a)));
 
1383
                                                                                                                                                                                        else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g6->m_baAtomType[z6t]])->GetAt(a6->GetAt(z6a)));
 
1384
                                                                                                                                                                        if ((!m_iRefOrSec[2][0]) || (obs == NULL))
 
1385
                                                                                                                                                                                vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g7->m_baAtomType[z7t]])->GetAt(a7->GetAt(z7a)));
 
1386
                                                                                                                                                                                        else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g7->m_baAtomType[z7t]])->GetAt(a7->GetAt(z7a)));
 
1387
                                                                                                                                                                        if ((!m_iRefOrSec[2][1]) || (obs == NULL))
 
1388
                                                                                                                                                                                vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g8->m_baAtomType[z8t]])->GetAt(a8->GetAt(z8a)));
 
1389
                                                                                                                                                                                        else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g8->m_baAtomType[z8t]])->GetAt(a8->GetAt(z8a)));
 
1390
                                                                                                                                                                        if ((!m_iRefOrSec[2][2]) || (obs == NULL))
 
1391
                                                                                                                                                                                vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g9->m_baAtomType[z9t]])->GetAt(a9->GetAt(z9a)));
 
1392
                                                                                                                                                                                        else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g9->m_baAtomType[z9t]])->GetAt(a9->GetAt(z9a)));
 
1393
                                                                                                                                                                }
 
1394
                                                                                                                                                        }
 
1395
                                                                                                                                                }
 
1396
                                                                                                                                        }
 
1397
                                                                                                                                }
 
1398
                                                                                                                        }
 
1399
                                                                                                                } else // IF NOT ORTHO[2]
 
1400
                                                                                                                {
 
1401
                                                                                                                        g7 = (CAtomGroup*)m_oaVectors[z*9+6];
 
1402
                                                                                                                        g8 = (CAtomGroup*)m_oaVectors[z*9+7];
 
1403
                                                                                                                        for (z7t=0;z7t<g7->m_baAtomType.GetSize();z7t++)
 
1404
                                                                                                                        {
 
1405
                                                                                                                                a7 = (CxIntArray*)g7->m_oaAtoms[z7t];
 
1406
                                                                                                                                for (z7a=0;z7a<a7->GetSize();z7a++)
 
1407
                                                                                                                                {
 
1408
                                                                                                                                        for (z8t=0;z8t<g8->m_baAtomType.GetSize();z8t++)
 
1409
                                                                                                                                        {
 
1410
                                                                                                                                                a8 = (CxIntArray*)g8->m_oaAtoms[z8t];
 
1411
                                                                                                                                                for (z8a=0;z8a<a8->GetSize();z8a++)
 
1412
                                                                                                                                                {
 
1413
                                                                                                                                                        if ((!m_iRefOrSec[0][0]) || (obs == NULL))
 
1414
                                                                                                                                                                vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g1->m_baAtomType[z1t]])->GetAt(a1->GetAt(z1a)));
 
1415
                                                                                                                                                                        else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g1->m_baAtomType[z1t]])->GetAt(a1->GetAt(z1a)));
 
1416
                                                                                                                                                        if ((!m_iRefOrSec[0][1]) || (obs == NULL))
 
1417
                                                                                                                                                                vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g2->m_baAtomType[z2t]])->GetAt(a2->GetAt(z2a)));
 
1418
                                                                                                                                                                        else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g2->m_baAtomType[z2t]])->GetAt(a2->GetAt(z2a)));
 
1419
                                                                                                                                                        vec->Add(0);
 
1420
                                                                                                                                                        if ((!m_iRefOrSec[1][0]) || (obs == NULL))
 
1421
                                                                                                                                                                vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g4->m_baAtomType[z4t]])->GetAt(a4->GetAt(z4a)));
 
1422
                                                                                                                                                                        else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g4->m_baAtomType[z4t]])->GetAt(a4->GetAt(z4a)));
 
1423
                                                                                                                                                        if ((!m_iRefOrSec[1][1]) || (obs == NULL))
 
1424
                                                                                                                                                                vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g5->m_baAtomType[z5t]])->GetAt(a5->GetAt(z5a)));
 
1425
                                                                                                                                                                        else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g5->m_baAtomType[z5t]])->GetAt(a5->GetAt(z5a)));
 
1426
                                                                                                                                                        if ((!m_iRefOrSec[1][2]) || (obs == NULL))
 
1427
                                                                                                                                                                vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g6->m_baAtomType[z6t]])->GetAt(a6->GetAt(z6a)));
 
1428
                                                                                                                                                                        else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g6->m_baAtomType[z6t]])->GetAt(a6->GetAt(z6a)));
 
1429
                                                                                                                                                        if ((!m_iRefOrSec[2][0]) || (obs == NULL))
 
1430
                                                                                                                                                                vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g7->m_baAtomType[z7t]])->GetAt(a7->GetAt(z7a)));
 
1431
                                                                                                                                                                        else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g7->m_baAtomType[z7t]])->GetAt(a7->GetAt(z7a)));
 
1432
                                                                                                                                                        if ((!m_iRefOrSec[2][1]) || (obs == NULL))
 
1433
                                                                                                                                                                vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g8->m_baAtomType[z8t]])->GetAt(a8->GetAt(z8a)));
 
1434
                                                                                                                                                                        else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g8->m_baAtomType[z8t]])->GetAt(a8->GetAt(z8a)));
 
1435
                                                                                                                                                        vec->Add(0);
 
1436
                                                                                                                                                }
 
1437
                                                                                                                                        }
 
1438
                                                                                                                                }
 
1439
                                                                                                                        }
 
1440
                                                                                                                } // END IF NOT ORTHO[2]
 
1441
                                                                                                        }
 
1442
                                                                                                }
 
1443
                                                                                        }
 
1444
                                                                                }
 
1445
                                                                        }
 
1446
                                                                }
 
1447
                                                        } else // IF NOT ORTHO[1]
 
1448
                                                        {
 
1449
                                                                g4 = (CAtomGroup*)m_oaVectors[z*9+3];
 
1450
                                                                g5 = (CAtomGroup*)m_oaVectors[z*9+4];
 
1451
                                                                for (z4t=0;z4t<g4->m_baAtomType.GetSize();z4t++)
 
1452
                                                                {
 
1453
                                                                        a4 = (CxIntArray*)g4->m_oaAtoms[z4t];
 
1454
                                                                        for (z4a=0;z4a<a4->GetSize();z4a++)
 
1455
                                                                        {
 
1456
                                                                                for (z5t=0;z5t<g5->m_baAtomType.GetSize();z5t++)
 
1457
                                                                                {
 
1458
                                                                                        a5 = (CxIntArray*)g5->m_oaAtoms[z5t];
 
1459
                                                                                        for (z5a=0;z5a<a5->GetSize();z5a++)
 
1460
                                                                                        {
 
1461
                                                                                                if (m_bOrtho[2])
 
1462
                                                                                                {
 
1463
                                                                                                        g7 = (CAtomGroup*)m_oaVectors[z*9+6];
 
1464
                                                                                                        g8 = (CAtomGroup*)m_oaVectors[z*9+7];
 
1465
                                                                                                        g9 = (CAtomGroup*)m_oaVectors[z*9+8];
 
1466
                                                                                                        for (z7t=0;z7t<g7->m_baAtomType.GetSize();z7t++)
 
1467
                                                                                                        {
 
1468
                                                                                                                a7 = (CxIntArray*)g7->m_oaAtoms[z7t];
 
1469
                                                                                                                for (z7a=0;z7a<a7->GetSize();z7a++)
 
1470
                                                                                                                {
 
1471
                                                                                                                        for (z8t=0;z8t<g8->m_baAtomType.GetSize();z8t++)
 
1472
                                                                                                                        {
 
1473
                                                                                                                                a8 = (CxIntArray*)g8->m_oaAtoms[z8t];
 
1474
                                                                                                                                for (z8a=0;z8a<a8->GetSize();z8a++)
 
1475
                                                                                                                                {
 
1476
                                                                                                                                        for (z9t=0;z9t<g9->m_baAtomType.GetSize();z9t++)
 
1477
                                                                                                                                        {
 
1478
                                                                                                                                                a9 = (CxIntArray*)g9->m_oaAtoms[z9t];
 
1479
                                                                                                                                                for (z9a=0;z9a<a9->GetSize();z9a++)
 
1480
                                                                                                                                                {
 
1481
                                                                                                                                                        if ((!m_iRefOrSec[0][0]) || (obs == NULL))
 
1482
                                                                                                                                                                vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g1->m_baAtomType[z1t]])->GetAt(a1->GetAt(z1a)));
 
1483
                                                                                                                                                                        else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g1->m_baAtomType[z1t]])->GetAt(a1->GetAt(z1a)));
 
1484
                                                                                                                                                        if ((!m_iRefOrSec[0][1]) || (obs == NULL))
 
1485
                                                                                                                                                                vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g2->m_baAtomType[z2t]])->GetAt(a2->GetAt(z2a)));
 
1486
                                                                                                                                                                        else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g2->m_baAtomType[z2t]])->GetAt(a2->GetAt(z2a)));
 
1487
                                                                                                                                                        vec->Add(0);
 
1488
                                                                                                                                                        if ((!m_iRefOrSec[1][0]) || (obs == NULL))
 
1489
                                                                                                                                                                vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g4->m_baAtomType[z4t]])->GetAt(a4->GetAt(z4a)));
 
1490
                                                                                                                                                                        else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g4->m_baAtomType[z4t]])->GetAt(a4->GetAt(z4a)));
 
1491
                                                                                                                                                        if ((!m_iRefOrSec[1][1]) || (obs == NULL))
 
1492
                                                                                                                                                                vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g5->m_baAtomType[z5t]])->GetAt(a5->GetAt(z5a)));
 
1493
                                                                                                                                                                        else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g5->m_baAtomType[z5t]])->GetAt(a5->GetAt(z5a)));
 
1494
                                                                                                                                                        vec->Add(0);
 
1495
                                                                                                                                                        if ((!m_iRefOrSec[2][0]) || (obs == NULL))
 
1496
                                                                                                                                                                vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g7->m_baAtomType[z7t]])->GetAt(a7->GetAt(z7a)));
 
1497
                                                                                                                                                                        else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g7->m_baAtomType[z7t]])->GetAt(a7->GetAt(z7a)));
 
1498
                                                                                                                                                        if ((!m_iRefOrSec[2][1]) || (obs == NULL))
 
1499
                                                                                                                                                                vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g8->m_baAtomType[z8t]])->GetAt(a8->GetAt(z8a)));
 
1500
                                                                                                                                                                        else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g8->m_baAtomType[z8t]])->GetAt(a8->GetAt(z8a)));
 
1501
                                                                                                                                                        if ((!m_iRefOrSec[2][2]) || (obs == NULL))
 
1502
                                                                                                                                                                vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g9->m_baAtomType[z9t]])->GetAt(a9->GetAt(z9a)));
 
1503
                                                                                                                                                                        else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g9->m_baAtomType[z9t]])->GetAt(a9->GetAt(z9a)));
 
1504
                                                                                                                                                }
 
1505
                                                                                                                                        }
 
1506
                                                                                                                                }
 
1507
                                                                                                                        }
 
1508
                                                                                                                }
 
1509
                                                                                                        }
 
1510
                                                                                                } else // IF NOT ORTHO[2]
 
1511
                                                                                                {
 
1512
                                                                                                        g7 = (CAtomGroup*)m_oaVectors[z*9+6];
 
1513
                                                                                                        g8 = (CAtomGroup*)m_oaVectors[z*9+7];
 
1514
                                                                                                        for (z7t=0;z7t<g7->m_baAtomType.GetSize();z7t++)
 
1515
                                                                                                        {
 
1516
                                                                                                                a7 = (CxIntArray*)g7->m_oaAtoms[z7t];
 
1517
                                                                                                                for (z7a=0;z7a<a7->GetSize();z7a++)
 
1518
                                                                                                                {
 
1519
                                                                                                                        for (z8t=0;z8t<g8->m_baAtomType.GetSize();z8t++)
 
1520
                                                                                                                        {
 
1521
                                                                                                                                a8 = (CxIntArray*)g8->m_oaAtoms[z8t];
 
1522
                                                                                                                                for (z8a=0;z8a<a8->GetSize();z8a++)
 
1523
                                                                                                                                {
 
1524
                                                                                                                                        if ((!m_iRefOrSec[0][0]) || (obs == NULL))
 
1525
                                                                                                                                                vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g1->m_baAtomType[z1t]])->GetAt(a1->GetAt(z1a)));
 
1526
                                                                                                                                                        else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g1->m_baAtomType[z1t]])->GetAt(a1->GetAt(z1a)));
 
1527
                                                                                                                                        if ((!m_iRefOrSec[0][1]) || (obs == NULL))
 
1528
                                                                                                                                                vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g2->m_baAtomType[z2t]])->GetAt(a2->GetAt(z2a)));
 
1529
                                                                                                                                                        else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g2->m_baAtomType[z2t]])->GetAt(a2->GetAt(z2a)));
 
1530
                                                                                                                                        vec->Add(0);
 
1531
                                                                                                                                        if ((!m_iRefOrSec[1][0]) || (obs == NULL))
 
1532
                                                                                                                                                vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g4->m_baAtomType[z4t]])->GetAt(a4->GetAt(z4a)));
 
1533
                                                                                                                                                        else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g4->m_baAtomType[z4t]])->GetAt(a4->GetAt(z4a)));
 
1534
                                                                                                                                        if ((!m_iRefOrSec[1][1]) || (obs == NULL))
 
1535
                                                                                                                                                vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g5->m_baAtomType[z5t]])->GetAt(a5->GetAt(z5a)));
 
1536
                                                                                                                                                        else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g5->m_baAtomType[z5t]])->GetAt(a5->GetAt(z5a)));
 
1537
                                                                                                                                        vec->Add(0);
 
1538
                                                                                                                                        if ((!m_iRefOrSec[2][0]) || (obs == NULL))
 
1539
                                                                                                                                                vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g7->m_baAtomType[z7t]])->GetAt(a7->GetAt(z7a)));
 
1540
                                                                                                                                                        else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g7->m_baAtomType[z7t]])->GetAt(a7->GetAt(z7a)));
 
1541
                                                                                                                                        if ((!m_iRefOrSec[2][1]) || (obs == NULL))
 
1542
                                                                                                                                                vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g8->m_baAtomType[z8t]])->GetAt(a8->GetAt(z8a)));
 
1543
                                                                                                                                                        else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g8->m_baAtomType[z8t]])->GetAt(a8->GetAt(z8a)));
 
1544
                                                                                                                                        vec->Add(0);
 
1545
                                                                                                                                }
 
1546
                                                                                                                        }
 
1547
                                                                                                                }
 
1548
                                                                                                        }
 
1549
                                                                                                } // END IF NOT ORTHO[2]
 
1550
                                                                                        }
 
1551
                                                                                }
 
1552
                                                                        }
 
1553
                                                                }
 
1554
                                                        } // END IF NOT ORTHO[1]
 
1555
                                                }
 
1556
                                        }
 
1557
                                }
 
1558
                        }
 
1559
                } // END IF NOT ORTHO[0]
 
1560
        } // END FOR ALL SETS
 
1561
        BXOUT;
 
1562
}
 
1563
 
 
1564
 
 
1565
void CPlDF::BuildAtomList(CSingleMolecule *ref, CSingleMolecule *obs, CxIntArray *vec)
 
1566
{
 
1567
        BXIN;
 
1568
        int z, z1t, z1a, z2t, z2a, z3t, z3a, z4t, z4a;
 
1569
        CAtomGroup *g1, *g2, *g3, *g4;
 
1570
        CxIntArray *a1, *a2, *a3, *a4;
 
1571
 
 
1572
        vec->RemoveAll_KeepSize();
 
1573
        for (z=0;z<m_oaVectors.GetSize()/4;z++)
 
1574
        {
 
1575
                if (m_bNormal)
 
1576
                {
 
1577
                        g1 = (CAtomGroup*)m_oaVectors[z*4];
 
1578
                        g2 = (CAtomGroup*)m_oaVectors[z*4+1];
 
1579
                        g4 = (CAtomGroup*)m_oaVectors[z*4+3];
 
1580
 
 
1581
                        for (z1t=0;z1t<g1->m_baAtomType.GetSize();z1t++)
 
1582
                        {
 
1583
                                a1 = (CxIntArray*)g1->m_oaAtoms[z1t];
 
1584
                                for (z1a=0;z1a<a1->GetSize();z1a++)
 
1585
                                {
 
1586
                                        for (z2t=0;z2t<g2->m_baAtomType.GetSize();z2t++)
 
1587
                                        {
 
1588
                                                a2 = (CxIntArray*)g2->m_oaAtoms[z2t];
 
1589
                                                for (z2a=0;z2a<a2->GetSize();z2a++)
 
1590
                                                {
 
1591
                                                        for (z4t=0;z4t<g4->m_baAtomType.GetSize();z4t++)
 
1592
                                                        {
 
1593
                                                                a4 = (CxIntArray*)g4->m_oaAtoms[z4t];
 
1594
                                                                for (z4a=0;z4a<a4->GetSize();z4a++)
 
1595
                                                                {
 
1596
                                                                        if ((!m_iRefOrSec[0]) || (obs == NULL))
 
1597
                                                                                vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g1->m_baAtomType[z1t]])->GetAt(a1->GetAt(z1a)));
 
1598
                                                                                        else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g1->m_baAtomType[z1t]])->GetAt(a1->GetAt(z1a)));
 
1599
                                                                        if ((!m_iRefOrSec[1]) || (obs == NULL))
 
1600
                                                                                vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g2->m_baAtomType[z2t]])->GetAt(a2->GetAt(z2a)));
 
1601
                                                                                        else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g2->m_baAtomType[z2t]])->GetAt(a2->GetAt(z2a)));
 
1602
                                                                        vec->Add(0);
 
1603
                                                                        if ((!m_iRefOrSec[3]) || (obs == NULL))
 
1604
                                                                                vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g4->m_baAtomType[z4t]])->GetAt(a4->GetAt(z4a)));
 
1605
                                                                                        else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g4->m_baAtomType[z4t]])->GetAt(a4->GetAt(z4a)));
 
1606
                                                                }
 
1607
                                                        }
 
1608
                                                }
 
1609
                                        }
 
1610
                                }
 
1611
                        }
 
1612
                } else // IF NOT NORMAL
 
1613
                {
 
1614
                        g1 = (CAtomGroup*)m_oaVectors[z*4];
 
1615
                        g2 = (CAtomGroup*)m_oaVectors[z*4+1];
 
1616
                        g3 = (CAtomGroup*)m_oaVectors[z*4+2];
 
1617
                        g4 = (CAtomGroup*)m_oaVectors[z*4+3];
 
1618
 
 
1619
                        for (z1t=0;z1t<g1->m_baAtomType.GetSize();z1t++)
 
1620
                        {
 
1621
                                a1 = (CxIntArray*)g1->m_oaAtoms[z1t];
 
1622
                                for (z1a=0;z1a<a1->GetSize();z1a++)
 
1623
                                {
 
1624
                                        for (z2t=0;z2t<g2->m_baAtomType.GetSize();z2t++)
 
1625
                                        {
 
1626
                                                a2 = (CxIntArray*)g2->m_oaAtoms[z2t];
 
1627
                                                for (z2a=0;z2a<a2->GetSize();z2a++)
 
1628
                                                {
 
1629
                                                        for (z3t=0;z3t<g3->m_baAtomType.GetSize();z3t++)
 
1630
                                                        {
 
1631
                                                                a3 = (CxIntArray*)g3->m_oaAtoms[z3t];
 
1632
                                                                for (z3a=0;z3a<a3->GetSize();z3a++)
 
1633
                                                                {
 
1634
                                                                        for (z4t=0;z4t<g4->m_baAtomType.GetSize();z4t++)
 
1635
                                                                        {
 
1636
                                                                                a4 = (CxIntArray*)g4->m_oaAtoms[z4t];
 
1637
                                                                                for (z4a=0;z4a<a4->GetSize();z4a++)
 
1638
                                                                                {
 
1639
                                                                                        if ((!m_iRefOrSec[0]) || (obs == NULL))
 
1640
                                                                                                vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g1->m_baAtomType[z1t]])->GetAt(a1->GetAt(z1a)));
 
1641
                                                                                                        else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g1->m_baAtomType[z1t]])->GetAt(a1->GetAt(z1a)));
 
1642
                                                                                        if ((!m_iRefOrSec[1]) || (obs == NULL))
 
1643
                                                                                                vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g2->m_baAtomType[z2t]])->GetAt(a2->GetAt(z2a)));
 
1644
                                                                                                        else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g2->m_baAtomType[z2t]])->GetAt(a2->GetAt(z2a)));
 
1645
                                                                                        if ((!m_iRefOrSec[2]) || (obs == NULL))
 
1646
                                                                                                vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g3->m_baAtomType[z3t]])->GetAt(a3->GetAt(z3a)));
 
1647
                                                                                                        else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g3->m_baAtomType[z3t]])->GetAt(a3->GetAt(z3a)));
 
1648
                                                                                        if ((!m_iRefOrSec[3]) || (obs == NULL))
 
1649
                                                                                                vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g4->m_baAtomType[z4t]])->GetAt(a4->GetAt(z4a)));
 
1650
                                                                                                        else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g4->m_baAtomType[z4t]])->GetAt(a4->GetAt(z4a)));
 
1651
                                                                                }
 
1652
                                                                        }
 
1653
                                                                }
 
1654
                                                        }
 
1655
                                                }
 
1656
                                        }
 
1657
                                }
 
1658
                        }
 
1659
                }
 
1660
        } // END FOR ALL SETS
 
1661
        BXOUT;
 
1662
}
 
1663
 
 
1664
 
 
1665
void CLiDF::BuildAtomList(CSingleMolecule *ref, CSingleMolecule *obs, CxIntArray *vec)
 
1666
{
 
1667
        BXIN;
 
1668
        int z, z1t, z1a, z2t, z2a, z3t, z3a, z4t, z4a;
 
1669
        CAtomGroup *g1, *g2, *g3, *g4;
 
1670
        CxIntArray *a1, *a2, *a3, *a4;
 
1671
 
 
1672
        vec->RemoveAll_KeepSize();
 
1673
        for (z=0;z<m_oaVectors.GetSize()/4;z++)
 
1674
        {
 
1675
                if (m_bNormal)
 
1676
                {
 
1677
                        g1 = (CAtomGroup*)m_oaVectors[z*4];
 
1678
                        g2 = (CAtomGroup*)m_oaVectors[z*4+1];
 
1679
                        g3 = (CAtomGroup*)m_oaVectors[z*4+2];
 
1680
                        g4 = (CAtomGroup*)m_oaVectors[z*4+3];
 
1681
 
 
1682
                        for (z1t=0;z1t<g1->m_baAtomType.GetSize();z1t++)
 
1683
                        {
 
1684
                                a1 = (CxIntArray*)g1->m_oaAtoms[z1t];
 
1685
                                for (z1a=0;z1a<a1->GetSize();z1a++)
 
1686
                                {
 
1687
                                        for (z2t=0;z2t<g2->m_baAtomType.GetSize();z2t++)
 
1688
                                        {
 
1689
                                                a2 = (CxIntArray*)g2->m_oaAtoms[z2t];
 
1690
                                                for (z2a=0;z2a<a2->GetSize();z2a++)
 
1691
                                                {
 
1692
                                                        for (z3t=0;z3t<g3->m_baAtomType.GetSize();z3t++)
 
1693
                                                        {
 
1694
                                                                a3 = (CxIntArray*)g3->m_oaAtoms[z3t];
 
1695
                                                                for (z3a=0;z3a<a3->GetSize();z3a++)
 
1696
                                                                {
 
1697
                                                                        for (z4t=0;z4t<g4->m_baAtomType.GetSize();z4t++)
 
1698
                                                                        {
 
1699
                                                                                a4 = (CxIntArray*)g4->m_oaAtoms[z4t];
 
1700
                                                                                for (z4a=0;z4a<a4->GetSize();z4a++)
 
1701
                                                                                {
 
1702
                                                                                        if ((!m_iRefOrSec[0]) || (obs == NULL))
 
1703
                                                                                                vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g1->m_baAtomType[z1t]])->GetAt(a1->GetAt(z1a)));
 
1704
                                                                                                        else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g1->m_baAtomType[z1t]])->GetAt(a1->GetAt(z1a)));
 
1705
                                                                                        if ((!m_iRefOrSec[1]) || (obs == NULL))
 
1706
                                                                                                vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g2->m_baAtomType[z2t]])->GetAt(a2->GetAt(z2a)));
 
1707
                                                                                                        else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g2->m_baAtomType[z2t]])->GetAt(a2->GetAt(z2a)));
 
1708
                                                                                        if ((!m_iRefOrSec[2]) || (obs == NULL))
 
1709
                                                                                                vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g3->m_baAtomType[z3t]])->GetAt(a3->GetAt(z3a)));
 
1710
                                                                                                        else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g3->m_baAtomType[z3t]])->GetAt(a3->GetAt(z3a)));
 
1711
                                                                                        if ((!m_iRefOrSec[3]) || (obs == NULL))
 
1712
                                                                                                vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g4->m_baAtomType[z4t]])->GetAt(a4->GetAt(z4a)));
 
1713
                                                                                                        else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g4->m_baAtomType[z4t]])->GetAt(a4->GetAt(z4a)));
 
1714
                                                                                }
 
1715
                                                                        }
 
1716
                                                                }
 
1717
                                                        }
 
1718
                                                }
 
1719
                                        }
 
1720
                                }
 
1721
                        }
 
1722
                } else // If not Normal
 
1723
                {
 
1724
                        g1 = (CAtomGroup*)m_oaVectors[z*4];
 
1725
                        g2 = (CAtomGroup*)m_oaVectors[z*4+1];
 
1726
                        g4 = (CAtomGroup*)m_oaVectors[z*4+3];
 
1727
 
 
1728
                        for (z1t=0;z1t<g1->m_baAtomType.GetSize();z1t++)
 
1729
                        {
 
1730
                                a1 = (CxIntArray*)g1->m_oaAtoms[z1t];
 
1731
                                for (z1a=0;z1a<a1->GetSize();z1a++)
 
1732
                                {
 
1733
                                        for (z2t=0;z2t<g2->m_baAtomType.GetSize();z2t++)
 
1734
                                        {
 
1735
                                                a2 = (CxIntArray*)g2->m_oaAtoms[z2t];
 
1736
                                                for (z2a=0;z2a<a2->GetSize();z2a++)
 
1737
                                                {
 
1738
                                                        for (z4t=0;z4t<g4->m_baAtomType.GetSize();z4t++)
 
1739
                                                        {
 
1740
                                                                a4 = (CxIntArray*)g4->m_oaAtoms[z4t];
 
1741
                                                                for (z4a=0;z4a<a4->GetSize();z4a++)
 
1742
                                                                {
 
1743
                                                                        if ((!m_iRefOrSec[0]) || (obs == NULL))
 
1744
                                                                                vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g1->m_baAtomType[z1t]])->GetAt(a1->GetAt(z1a)));
 
1745
                                                                                        else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g1->m_baAtomType[z1t]])->GetAt(a1->GetAt(z1a)));
 
1746
                                                                        if ((!m_iRefOrSec[1]) || (obs == NULL))
 
1747
                                                                                vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g2->m_baAtomType[z2t]])->GetAt(a2->GetAt(z2a)));
 
1748
                                                                                        else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g2->m_baAtomType[z2t]])->GetAt(a2->GetAt(z2a)));
 
1749
                                                                        vec->Add(0);
 
1750
                                                                        if ((!m_iRefOrSec[3]) || (obs == NULL))
 
1751
                                                                                vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g4->m_baAtomType[z4t]])->GetAt(a4->GetAt(z4a)));
 
1752
                                                                                        else vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g4->m_baAtomType[z4t]])->GetAt(a4->GetAt(z4a)));
 
1753
                                                                }
 
1754
                                                        }
 
1755
                                                }
 
1756
                                        }
 
1757
                                }
 
1758
                        }
 
1759
                }
 
1760
        } // END FOR ALL SETS
 
1761
        BXOUT;
 
1762
}
 
1763
 
 
1764
 
 
1765
void CRDF::BuildName()
 
1766
{
 
1767
        BTIN;
 
1768
        int z;
 
1769
        char tmp[256];
 
1770
 
 
1771
        tmp[0] = 0;
 
1772
        if (m_iDeriv != 0)
 
1773
                sprintf(tmp,"deriv%d_",m_iDeriv);
 
1774
        for (z=0;z<m_oaVectors.GetSize()/2;z++)
 
1775
        {
 
1776
                strcat(tmp,"[");
 
1777
 
 
1778
                strcat(tmp,((CAtomGroup*)m_oaVectors[z*2])->m_sName);
 
1779
                if (m_iRefOrSec[0])
 
1780
                        strcat(tmp,"o_");
 
1781
                                else strcat(tmp,"r_");
 
1782
                strcat(tmp,((CAtomGroup*)m_oaVectors[z*2+1])->m_sName);
 
1783
                if (m_iRefOrSec[1])
 
1784
                        strcat(tmp,"o");
 
1785
                                else strcat(tmp,"r");
 
1786
 
 
1787
                if (z < (m_oaVectors.GetSize()/2)-1)
 
1788
                        strcat(tmp,"],");
 
1789
                                else strcat(tmp,"]");
 
1790
        }
 
1791
 
 
1792
        try { m_sShortName = new char[strlen(tmp)+1]; } catch(...) { m_sShortName = NULL; }
 
1793
        if (m_sShortName == NULL) NewException((double)(strlen(tmp)+1)*sizeof(char),__FILE__,__LINE__,__PRETTY_FUNCTION__);
 
1794
        
 
1795
        strcpy(m_sShortName,tmp);
 
1796
        if (m_iShowMol != -1)
 
1797
                sprintf(tmp,"%s_%s%d_%s_",((CMolecule*)g_oaMolecules[g_iFixMol])->m_sName,((CAtom*)g_oaAtoms[g_iFixRealAtomType[0]])->m_sName,g_iFixAtom[0]+1,((CMolecule*)g_oaMolecules[m_iShowMol])->m_sName);
 
1798
                        else sprintf(tmp,"%s_%s%d_",((CMolecule*)g_oaMolecules[g_iFixMol])->m_sName,((CAtom*)g_oaAtoms[g_iFixRealAtomType[0]])->m_sName,g_iFixAtom[0]+1);
 
1799
        strcat(tmp,m_sShortName);
 
1800
 
 
1801
        try { m_sName = new char[strlen(tmp)+1]; } catch(...) { m_sName = NULL; }
 
1802
        if (m_sName == NULL) NewException((double)(strlen(tmp)+1)*sizeof(char),__FILE__,__LINE__,__PRETTY_FUNCTION__);
 
1803
        
 
1804
        strcpy(m_sName,tmp);
 
1805
 
 
1806
        BTOUT;
 
1807
}
 
1808
 
 
1809
 
 
1810
void CDensDF::BuildName()
 
1811
{
 
1812
        BTIN;
 
1813
        char tmp[256];
 
1814
        int z;
 
1815
 
 
1816
        sprintf(tmp,"%s_%s%d_%s",((CMolecule*)g_oaMolecules[m_iShowMol])->m_sName,((CAtom*)g_oaAtoms[m_iCenterAtomRealType])->m_sName,m_iCenterAtom+1,(m_bDensityMass?"mass":"particle"));
 
1817
 
 
1818
        for (z=0;z<g_oaMolecules.GetSize();z++)
 
1819
        {
 
1820
                if (!m_pDensityMolSelect[z])
 
1821
                        continue;
 
1822
                strcat(tmp,"_");
 
1823
                strcat(tmp,((CMolecule*)g_oaMolecules[z])->m_sName);
 
1824
                if (!m_pDensityMolAG[z]->m_bAllAtoms)
 
1825
                {
 
1826
                        strcat(tmp,"_");
 
1827
                        strcat(tmp,m_pDensityMolAG[z]->m_sName);
 
1828
                }
 
1829
        }
 
1830
 
 
1831
        try { m_sName = new char[strlen(tmp)+1]; } catch(...) { m_sName = NULL; }
 
1832
        if (m_sName == NULL) NewException((double)(strlen(tmp)+1)*sizeof(char),__FILE__,__LINE__,__PRETTY_FUNCTION__);
 
1833
        
 
1834
        strcpy(m_sName,tmp);
 
1835
        BTOUT;
 
1836
}
 
1837
 
 
1838
 
 
1839
void CVHDF::BuildName()
 
1840
{
 
1841
        BTIN;
 
1842
        int z;
 
1843
        char tmp[256];
 
1844
 
 
1845
        tmp[0] = 0;
 
1846
        for (z=0;z<m_oaVectors.GetSize()/2;z++)
 
1847
        {
 
1848
                strcat(tmp,"[");
 
1849
 
 
1850
                strcat(tmp,((CAtomGroup*)m_oaVectors[z*2])->m_sName);
 
1851
                if (m_iRefOrSec[0])
 
1852
                        strcat(tmp,"o_");
 
1853
                                else strcat(tmp,"r_");
 
1854
                strcat(tmp,((CAtomGroup*)m_oaVectors[z*2+1])->m_sName);
 
1855
                if (m_iRefOrSec[1])
 
1856
                        strcat(tmp,"o");
 
1857
                                else strcat(tmp,"r");
 
1858
 
 
1859
                if (z < (m_oaVectors.GetSize()/2)-1)
 
1860
                        strcat(tmp,"],");
 
1861
                                else strcat(tmp,"]");
 
1862
        }
 
1863
 
 
1864
        try { m_sShortName = new char[strlen(tmp)+1]; } catch(...) { m_sShortName = NULL; }
 
1865
        if (m_sShortName == NULL) NewException((double)(strlen(tmp)+1)*sizeof(char),__FILE__,__LINE__,__PRETTY_FUNCTION__);
 
1866
        
 
1867
        strcpy(m_sShortName,tmp);
 
1868
        if (m_iShowMol != -1)
 
1869
                sprintf(tmp,"%s_%s%d_%s_",((CMolecule*)g_oaMolecules[g_iFixMol])->m_sName,((CAtom*)g_oaAtoms[g_iFixRealAtomType[0]])->m_sName,g_iFixAtom[0]+1,((CMolecule*)g_oaMolecules[m_iShowMol])->m_sName);
 
1870
                        else sprintf(tmp,"%s_%s%d_",((CMolecule*)g_oaMolecules[g_iFixMol])->m_sName,((CAtom*)g_oaAtoms[g_iFixRealAtomType[0]])->m_sName,g_iFixAtom[0]+1);
 
1871
        strcat(tmp,m_sShortName);
 
1872
 
 
1873
        try { m_sName = new char[strlen(tmp)+1]; } catch(...) { m_sName = NULL; }
 
1874
        if (m_sName == NULL) NewException((double)(strlen(tmp)+1)*sizeof(char),__FILE__,__LINE__,__PRETTY_FUNCTION__);
 
1875
        
 
1876
        strcpy(m_sName,tmp);
 
1877
        BTOUT;
 
1878
}
 
1879
 
 
1880
 
 
1881
void CRDF::Parse()
 
1882
{
 
1883
        BTIN;
 
1884
        char buf[256];
 
1885
        int ti;
 
1886
        CAtomGroup *ag;
 
1887
 
 
1888
        try { m_pRDF = new CDF(); } catch(...) { m_pRDF = NULL; }
 
1889
        if (m_pRDF == NULL) NewException((double)sizeof(CDF),__FILE__,__LINE__,__PRETTY_FUNCTION__);
 
1890
        
 
1891
        m_iShowAtomGes = 0;
 
1892
        m_iRefAtomGes = 0;
 
1893
        m_iCombinations = 0;
 
1894
        mprintf(WHITE,"\n>>> Radial Distribution Function >>>\n\n");
 
1895
/*      if (m_bSelf)
 
1896
        {
 
1897
                m_iRefOrSec[0] = 0;
 
1898
                m_iRefOrSec[1] = 0;
 
1899
        } else
 
1900
        {
 
1901
                m_iRefOrSec[0] = 0;
 
1902
                m_iRefOrSec[1] = 1;
 
1903
        }*/
 
1904
        if (m_iShowMol != -1)
 
1905
                m_iRefOrSec[0] = AskRangeInteger("    Take reference atom(s) from RM %s (0) or from OM %s (1)? [0] ",0,1,0,((CMolecule*)g_oaMolecules[g_iFixMol])->m_sName,((CMolecule*)g_oaMolecules[m_iShowMol])->m_sName);
 
1906
                        else m_iRefOrSec[0] = 0; // Kein OM: Nimm alles aus RM
 
1907
        if (m_iShowMol != -1)
 
1908
                m_iRefOrSec[1] = AskRangeInteger("    Take observed atom(s) from RM %s (0) or from OM %s (1)? [1] ",0,1,1,((CMolecule*)g_oaMolecules[g_iFixMol])->m_sName,((CMolecule*)g_oaMolecules[m_iShowMol])->m_sName);
 
1909
                        else m_iRefOrSec[1] = 0; // Kein OM: Nimm alles aus RM
 
1910
                
 
1911
_rdfnewset:
 
1912
        mprintf("\n");
 
1913
 
 
1914
        try { ag = new CAtomGroup(); } catch(...) { ag = NULL; }
 
1915
        if (ag == NULL) NewException((double)sizeof(CAtomGroup),__FILE__,__LINE__,__PRETTY_FUNCTION__);
 
1916
        
 
1917
_rdfatom1:
 
1918
        // 1 reales + 2 virtuelle = 3 gesamt
 
1919
        if (((CMolecule*)g_oaMolecules[(m_iRefOrSec[0])?m_iShowMol:g_iFixMol])->m_iAtomGes == 3)
 
1920
        {
 
1921
                mprintf("    %s is only one atom, there is no choice.\n",((CMolecule*)g_oaMolecules[(m_iRefOrSec[0])?m_iShowMol:g_iFixMol])->m_sName);
 
1922
                ag->Reset();
 
1923
                ag->m_pMolecule = (CMolecule*)g_oaMolecules[(m_iRefOrSec[0])?m_iShowMol:g_iFixMol];
 
1924
                ag->AddAtom(0,0,false);
 
1925
                ag->SortAtoms();
 
1926
                ag->BuildName();
 
1927
        } else
 
1928
        {
 
1929
                if (m_iRefOrSec[0])
 
1930
                {
 
1931
                        mprintf("    Which atom(s) to take from OM %s (e.g. \"C1,C3-5,H\", \"*\"=all)? [#2] ",((CMolecule*)g_oaMolecules[m_iShowMol])->m_sName);
 
1932
                        inpprintf("! Which atom(s) to take from OM %s (e.g. \"C1,C3-5,H\", \"*\"=all)? [#2]\n",((CMolecule*)g_oaMolecules[m_iShowMol])->m_sName);
 
1933
                } else
 
1934
                {
 
1935
                        mprintf("    Which atom(s) to take from RM %s (e.g. \"C1,C3-5,H\", \"*\"=all)? [#2] ",((CMolecule*)g_oaMolecules[g_iFixMol])->m_sName);
 
1936
                        inpprintf("! Which atom(s) to take from RM %s (e.g. \"C1,C3-5,H\", \"*\"=all)? [#2]\n",((CMolecule*)g_oaMolecules[g_iFixMol])->m_sName);
 
1937
                }
 
1938
                myget(buf);
 
1939
                if (strlen(buf) == 0)
 
1940
                {
 
1941
                        if (!ag->ParseAtoms((CMolecule*)g_oaMolecules[(m_iRefOrSec[0])?m_iShowMol:g_iFixMol],"#2"))
 
1942
                        {
 
1943
                                eprintf("Weird error.\n");
 
1944
                                goto _rdfatom1;
 
1945
                        }
 
1946
                } else if (!ag->ParseAtoms((CMolecule*)g_oaMolecules[(m_iRefOrSec[0])?m_iShowMol:g_iFixMol],buf))
 
1947
                        goto _rdfatom1;
 
1948
        }
 
1949
        m_oaVectors.Add(ag);
 
1950
        m_iRefAtomGes += ag->m_iAtomGes;
 
1951
        ti = ag->m_iAtomGes;
 
1952
 
 
1953
        try { ag = new CAtomGroup(); } catch(...) { ag = NULL; }
 
1954
        if (ag == NULL) NewException((double)sizeof(CAtomGroup),__FILE__,__LINE__,__PRETTY_FUNCTION__);
 
1955
        
 
1956
_rdfatom2:
 
1957
        if (((CMolecule*)g_oaMolecules[(m_iRefOrSec[1])?m_iShowMol:g_iFixMol])->m_iAtomGes == 3)
 
1958
        {
 
1959
                mprintf("    %s is only one atom, there is no choice.\n",((CMolecule*)g_oaMolecules[(m_iRefOrSec[1])?m_iShowMol:g_iFixMol])->m_sName);
 
1960
                ag->Reset();
 
1961
                ag->m_pMolecule = (CMolecule*)g_oaMolecules[(m_iRefOrSec[1])?m_iShowMol:g_iFixMol];
 
1962
                ag->AddAtom(0,0,false);
 
1963
                ag->SortAtoms();
 
1964
                ag->BuildName();
 
1965
        } else
 
1966
        {
 
1967
                if (m_iRefOrSec[1])
 
1968
                {
 
1969
                        mprintf("    Which atom(s) to take from OM %s (e.g. \"C1,C3-5,H\", \"*\"=all)? [#2] ",((CMolecule*)g_oaMolecules[m_iShowMol])->m_sName);
 
1970
                        inpprintf("! Which atom(s) to take from OM %s (e.g. \"C1,C3-5,H\", \"*\"=all)? [#2]\n",((CMolecule*)g_oaMolecules[m_iShowMol])->m_sName);
 
1971
                } else
 
1972
                {
 
1973
                        mprintf("    Which atom(s) to take from RM %s (e.g. \"C1,C3-5,H\", \"*\"=all)? [#2] ",((CMolecule*)g_oaMolecules[g_iFixMol])->m_sName);
 
1974
                        inpprintf("! Which atom(s) to take from RM %s (e.g. \"C1,C3-5,H\", \"*\"=all)? [#2]\n",((CMolecule*)g_oaMolecules[g_iFixMol])->m_sName);
 
1975
                }
 
1976
                myget(buf);
 
1977
 
 
1978
                try { ag = new CAtomGroup(); } catch(...) { ag = NULL; }
 
1979
                if (ag == NULL) NewException((double)sizeof(CAtomGroup),__FILE__,__LINE__,__PRETTY_FUNCTION__);
 
1980
 
 
1981
                if (strlen(buf) == 0)
 
1982
                {
 
1983
                        if (!ag->ParseAtoms((CMolecule*)g_oaMolecules[(m_iRefOrSec[1])?m_iShowMol:g_iFixMol],"#2"))
 
1984
                        {
 
1985
                                eprintf("Weird error.\n");
 
1986
                                goto _rdfatom2;
 
1987
                        }
 
1988
                } else if (!ag->ParseAtoms((CMolecule*)g_oaMolecules[(m_iRefOrSec[1])?m_iShowMol:g_iFixMol],buf))
 
1989
                        goto _rdfatom2;
 
1990
        }
 
1991
        m_oaVectors.Add(ag);
 
1992
        m_iShowAtomGes += ag->m_iAtomGes;
 
1993
        m_iCombinations += ti * ag->m_iAtomGes;
 
1994
 
 
1995
        if (g_bAdvanced2)
 
1996
                if (AskYesNo("    Add another set of atoms to this (!) RDF (y/n)? [no] ",false))
 
1997
                        goto _rdfnewset;
 
1998
 
 
1999
        mprintf("    This yields in %d combinations.\n\n",m_iCombinations);
 
2000
 
 
2001
        ParseDeriv();
 
2002
 
 
2003
        switch(m_iDeriv)
 
2004
        {
 
2005
                case 0:
 
2006
                        m_fMinDist = AskFloat("    Enter the minimal radius of this RDF in pm: [0] ",0.0f);
 
2007
                        m_fMaxDist = AskFloat("    Enter the maximal radius of this RDF in pm: [%d.0] ",(float)HalfBox(),HalfBox());
 
2008
                        break;
 
2009
                case 1:
 
2010
                        if (m_bDerivAbs)
 
2011
                                m_fMinDist = AskFloat("    Enter the minimal value of this d1-RDF in pm/ps: [0] ",0.0f);
 
2012
                                        else m_fMinDist = AskFloat("    Enter the minimal value of this d1-RDF in pm/ps: [-10.0] ",-10.0f);
 
2013
                        m_fMaxDist = AskFloat("    Enter the maximal value of this d1-RDF in pm/ps: [10.0] ",10.0f);
 
2014
                        break;
 
2015
                case 2:
 
2016
                        if (m_bDerivAbs)
 
2017
                                m_fMinDist = AskFloat("    Enter the minimal value of this d2-RDF in pm/ps^2: [0] ",0.0f);
 
2018
                                        else m_fMinDist = AskFloat("    Enter the minimal value of this d2-RDF in pm/ps^2: [-10.0] ",-10.0f);
 
2019
                        m_fMaxDist = AskFloat("    Enter the maximal value of this d2-RDF in pm/ps^2: [10.0] ",10.0f);
 
2020
                        break;
 
2021
        }
 
2022
        m_bAdaptive = false/*AskYesNo("    Enter binning resolution (n) or use adaptive binnig (y)? [no] ",false)*/;
 
2023
        if (!m_bAdaptive)
 
2024
                m_iResolution = AskUnsignedInteger("    Enter the resolution (bin count) for this RDF: [300] ",/*(int)((m_fMaxDist-m_fMinDist)/10.0f),(int)((m_fMaxDist-m_fMinDist)/10.0f)*/300);
 
2025
                        else m_iResolution = 65536;
 
2026
 
 
2027
        if (g_bAdvanced2)
 
2028
                m_iHistogramRes = AskUnsignedInteger("    Please enter histogram resolution (0=no histogram): [5000] ",5000);
 
2029
                        else m_iHistogramRes = 0;
 
2030
 
 
2031
        if (m_iDeriv == 0)
 
2032
        {
 
2033
                if (m_iShowMol != -1)
 
2034
                        m_bRadialCorrect = AskYesNo("    Correct radial distribution for this RDF (y/n)? [yes] ",true);
 
2035
                                else m_bRadialCorrect = AskYesNo("    Correct radial distribution for this RDF (y/n)? [no] ",false);
 
2036
        } else m_bRadialCorrect = false;
 
2037
 
 
2038
        if (g_bAdvanced2 && m_bRadialCorrect)
 
2039
                m_bProbDens = AskYesNo("    Compute occurence in nm^(-3) (y) or rel. to uniform density (n)? [no] ",false);
 
2040
                        else m_bProbDens = false;
 
2041
 
 
2042
        if (g_bBetaFeatures)
 
2043
        {
 
2044
                m_bLongMode = AskYesNo("    Use correction trick for longer RDFs (y/n)? [no] ",false);
 
2045
                m_bCalcSD = AskYesNo("    Calculate standard deviation for this RDF (y/n)? [no] ",false);
 
2046
        } else
 
2047
        {
 
2048
                m_bCalcSD = false;
 
2049
                m_bLongMode = false;
 
2050
        }
 
2051
 
 
2052
        if (m_bCalcSD)
 
2053
        {
 
2054
                m_iSDBlocks = AskUnsignedInteger("    How many different block lenghts to use? [100] ",100);
 
2055
                m_iSDBlockMin = AskUnsignedInteger("    Enter minimal block length in time steps: [1] ",1);
 
2056
                if (g_iTrajSteps != -1)
 
2057
                        m_iSDBlockMax = AskUnsignedInteger("    Enter maximal block length in time steps: [%d] ",g_iTrajSteps/10,g_iTrajSteps/10);
 
2058
                                else m_iSDBlockMax = AskUnsignedInteger("    Enter maximal block length in time steps: [1000] ",1000);
 
2059
                m_bSDVerbose = AskYesNo("    Write out correlation length extrapolation fit data for each bin (y/n)? [no] ",false);
 
2060
                m_fSDTimesSigma = AskFloat("    Use which factor of sigma for confidence range? [3.0] ",3.0);
 
2061
                mprintf("\n    %.2f sigma leads to a confidence level of %.5f%c.\n",m_fSDTimesSigma,2.0*NormalDistIntegral(m_fSDTimesSigma)-1.0,'%');
 
2062
        }
 
2063
 
 
2064
        BuildName();
 
2065
        mprintf(WHITE,"\n<<< End of Radial Distribution Function <<<\n\n");
 
2066
        BTOUT;
 
2067
}
 
2068
 
 
2069
 
 
2070
void CDensDF::Parse()
 
2071
{
 
2072
        BTIN;
 
2073
        char buf[256];
 
2074
        int z;
 
2075
        CMolecule *m;
 
2076
 
 
2077
        try { m_pDensDF = new CDF(); } catch(...) { m_pDensDF = NULL; }
 
2078
        if (m_pDensDF == NULL) NewException((double)sizeof(CDF),__FILE__,__LINE__,__PRETTY_FUNCTION__);
 
2079
        
 
2080
        mprintf(WHITE,"\n>>> Density Distribution Function >>>\n\n");
 
2081
 
 
2082
        m_bDensityMass = AskYesNo("    Observe mass density (y) or particle density (n)? [yes] ",true);
 
2083
 
 
2084
        mprintf("\n    Choose a reference atom around which the density will be analyzed.\n\n");
 
2085
 
 
2086
        // 1 reales + 2 virtuelle = 3 gesamt
 
2087
        if (((CMolecule*)g_oaMolecules[m_iShowMol])->m_iAtomGesNoVirt == 1)
 
2088
        {
 
2089
                mprintf("    %s is only one atom, there is no choice.\n",((CMolecule*)g_oaMolecules[m_iShowMol])->m_sName);
 
2090
                if (!ParseAtom("#2",m_iShowMol,m_iCenterAtomType,m_iCenterAtomRealType,m_iCenterAtom))
 
2091
                {
 
2092
                        eprintf("Weird error.\n");
 
2093
                        abort();
 
2094
                }
 
2095
        } else
 
2096
        {
 
2097
_densatom1:
 
2098
                mprintf("    Which atom to take from OM %s (e.g. C1)? [#2] ",((CMolecule*)g_oaMolecules[m_iShowMol])->m_sName);
 
2099
                inpprintf("! Which atom to take from OM %s (e.g. C1)? [#2]\n",((CMolecule*)g_oaMolecules[m_iShowMol])->m_sName);
 
2100
                myget(buf);
 
2101
                if (strlen(buf) == 0)
 
2102
                {
 
2103
                        if (!ParseAtom("#2",m_iShowMol,m_iCenterAtomType,m_iCenterAtomRealType,m_iCenterAtom))
 
2104
                        {
 
2105
                                eprintf("Weird error.\n");
 
2106
                                abort();
 
2107
                        }
 
2108
                } else if (!ParseAtom(buf,m_iShowMol,m_iCenterAtomType,m_iCenterAtomRealType,m_iCenterAtom))
 
2109
                        goto _densatom1;
 
2110
        }
 
2111
 
 
2112
        try { m_pDensityMolSelect = new bool[g_oaMolecules.GetSize()]; } catch(...) { m_pDensityMolSelect = NULL; }
 
2113
        if (m_pDensityMolSelect == NULL) NewException((double)g_oaMolecules.GetSize()*sizeof(bool),__FILE__,__LINE__,__PRETTY_FUNCTION__);
 
2114
 
 
2115
        try { m_pDensityMolAG = new CAtomGroup*[g_oaMolecules.GetSize()]; } catch(...) { m_pDensityMolAG = NULL; }
 
2116
        if (m_pDensityMolAG == NULL) NewException((double)g_oaMolecules.GetSize()*sizeof(CAtomGroup*),__FILE__,__LINE__,__PRETTY_FUNCTION__);
 
2117
        
 
2118
        mprintf("\n    Please choose the atoms to observe:\n\n");
 
2119
 
 
2120
        for (z=0;z<g_oaMolecules.GetSize();z++)
 
2121
        {
 
2122
                m = (CMolecule*)g_oaMolecules[z];
 
2123
                m_pDensityMolSelect[z] = AskYesNo("    Consider contributions from %s (y/n)? [%s] ",!m->m_bPseudo,((CMolecule*)g_oaMolecules[z])->m_sName,m->m_bPseudo?"no":"yes");
 
2124
                if (m_pDensityMolSelect[z])
 
2125
                {
 
2126
                        try { m_pDensityMolAG[z] = new CAtomGroup(); } catch(...) { m_pDensityMolAG[z] = NULL; }
 
2127
                        if (m_pDensityMolAG[z] == NULL) NewException((double)sizeof(CAtomGroup),__FILE__,__LINE__,__PRETTY_FUNCTION__);
 
2128
_densatom2:
 
2129
                        AskString("      Which atoms from %s to observe (e.g. C1-3,C6,N)? [all] ",buf,"",m->m_sName);
 
2130
                        if (strlen(buf) == 0)
 
2131
                        {
 
2132
                                m_pDensityMolAG[z]->AddAllAtoms(m,false);
 
2133
                        } else if (!m_pDensityMolAG[z]->ParseAtoms(m,buf))
 
2134
                                goto _densatom2;
 
2135
                }
 
2136
        }
 
2137
 
 
2138
        mprintf("\n");
 
2139
 
 
2140
        m_fMinDist = AskFloat("    Enter the minimal radius of this Density DF in pm: [0] ",0.0f);
 
2141
        m_fMaxDist = AskFloat("    Enter the maximal radius of this Density DF in pm: [%d.0] ",(float)HalfBox(),HalfBox());
 
2142
 
 
2143
        m_iResolution = AskUnsignedInteger("    Enter the resolution (bin count) for this Density DF: [300] ",300);
 
2144
 
 
2145
        if (g_bAdvanced2)
 
2146
                m_iHistogramRes = AskUnsignedInteger("    Please enter histogram resolution (0=no histogram): [5000] ",5000);
 
2147
                        else m_iHistogramRes = 0;
 
2148
 
 
2149
        BuildName();
 
2150
        mprintf(WHITE,"\n<<< End of Density Distribution Function <<<\n\n");
 
2151
        BTOUT;
 
2152
}
 
2153
 
 
2154
 
 
2155
void CRDF::ParseCondition(int rm, CNbSearch *n, bool nbana)
 
2156
{
 
2157
        BTIN;
 
2158
        char buf[256];
 
2159
        int ti;
 
2160
        CAtomGroup *ag;
 
2161
 
 
2162
        try { m_pRDF = new CDF(); } catch(...) { m_pRDF = NULL; }
 
2163
        if (m_pRDF == NULL) NewException((double)sizeof(CDF),__FILE__,__LINE__,__PRETTY_FUNCTION__);
 
2164
        
 
2165
        m_iShowAtomGes = 0;
 
2166
        m_iRefAtomGes = 0;
 
2167
        m_iCombinations = 0;
 
2168
        m_iRefOrSec[0] = 0;
 
2169
        m_iRefOrSec[1] = 1;
 
2170
        mprintf(WHITE,"\n>>> Distance Condition >>>\n");
 
2171
        
 
2172
_rdfnewset:
 
2173
        mprintf("\n");
 
2174
 
 
2175
        try { ag = new CAtomGroup(); } catch(...) { ag = NULL; }
 
2176
        if (ag == NULL) NewException((double)sizeof(CAtomGroup),__FILE__,__LINE__,__PRETTY_FUNCTION__);
 
2177
 
 
2178
_rdfatom1:
 
2179
        if (((CMolecule*)g_oaMolecules[rm])->m_iAtomGes == 3)
 
2180
        {
 
2181
                mprintf("    %s is only one atom, there is no choice.\n",((CMolecule*)g_oaMolecules[rm])->m_sName);
 
2182
                ag->Reset();
 
2183
                ag->m_pMolecule = (CMolecule*)g_oaMolecules[rm];
 
2184
                ag->AddAtom(0,0,false);
 
2185
                ag->SortAtoms();
 
2186
                ag->BuildName();
 
2187
        } else
 
2188
        {
 
2189
                mprintf("    Which atom(s) to take from RM %s (e.g. \"C1,C3-5,H\", \"*\"=all)? [#2] ",((CMolecule*)g_oaMolecules[rm])->m_sName);
 
2190
                inpprintf("! Which atom(s) to take from RM %s (e.g. \"C1,C3-5,H\", \"*\"=all)? [#2]\n",((CMolecule*)g_oaMolecules[rm])->m_sName);
 
2191
                myget(buf);
 
2192
                if (strlen(buf) == 0)
 
2193
                {
 
2194
                        if (!ag->ParseAtoms((CMolecule*)g_oaMolecules[rm],"#2"))
 
2195
                        {
 
2196
                                eprintf("Weird error.\n");
 
2197
                                goto _rdfatom1;
 
2198
                        }
 
2199
                } else if (!ag->ParseAtoms((CMolecule*)g_oaMolecules[rm],buf))
 
2200
                        goto _rdfatom1;
 
2201
        }
 
2202
        m_oaVectors.Add(ag);
 
2203
        m_iRefAtomGes += ag->m_iAtomGes;
 
2204
        ti = ag->m_iAtomGes;
 
2205
 
 
2206
        try { ag = new CAtomGroup(); } catch(...) { ag = NULL; }
 
2207
        if (ag == NULL) NewException((double)sizeof(CAtomGroup),__FILE__,__LINE__,__PRETTY_FUNCTION__);
 
2208
 
 
2209
_rdfatom2:
 
2210
        if (((CMolecule*)g_oaMolecules[m_iShowMol])->m_iAtomGes == 3)
 
2211
        {
 
2212
                mprintf("    %s is only one atom, there is no choice.\n",((CMolecule*)g_oaMolecules[m_iShowMol])->m_sName);
 
2213
                ag->Reset();
 
2214
                ag->m_pMolecule = (CMolecule*)g_oaMolecules[m_iShowMol];
 
2215
                ag->AddAtom(0,0,false);
 
2216
                ag->SortAtoms();
 
2217
                ag->BuildName();
 
2218
        } else
 
2219
        {
 
2220
                mprintf("    Which atom(s) to take from OM %s (e.g. \"C1,C3-5,H\", \"*\"=all)? [#2] ",((CMolecule*)g_oaMolecules[m_iShowMol])->m_sName);
 
2221
                inpprintf("! Which atom(s) to take from OM %s (e.g. \"C1,C3-5,H\", \"*\"=all)? [#2]\n",((CMolecule*)g_oaMolecules[m_iShowMol])->m_sName);
 
2222
                myget(buf);
 
2223
 
 
2224
                try { ag = new CAtomGroup(); } catch(...) { ag = NULL; }
 
2225
                if (ag == NULL) NewException((double)sizeof(CAtomGroup),__FILE__,__LINE__,__PRETTY_FUNCTION__);
 
2226
 
 
2227
                if (strlen(buf) == 0)
 
2228
                {
 
2229
                        if (!ag->ParseAtoms((CMolecule*)g_oaMolecules[m_iShowMol],"#2"))
 
2230
                        {
 
2231
                                eprintf("Weird error.\n");
 
2232
                                goto _rdfatom2;
 
2233
                        }
 
2234
                } else if (!ag->ParseAtoms((CMolecule*)g_oaMolecules[m_iShowMol],buf))
 
2235
                        goto _rdfatom2;
 
2236
        }
 
2237
        m_oaVectors.Add(ag);
 
2238
        m_iShowAtomGes += ag->m_iAtomGes;
 
2239
        m_iCombinations += ti * ag->m_iAtomGes;
 
2240
 
 
2241
        if (AskYesNo("    Enter another set of atoms for this condition (y/n)? [no] ",false))
 
2242
                goto _rdfnewset;
 
2243
 
 
2244
        if (!nbana)
 
2245
        {
 
2246
                if (AskUnsignedInteger("\n    Enter min./max. distance (0) or min./max. nearest neighbor count (1)? [0] ",0)==0)
 
2247
                {
 
2248
                        g_bEnvDisableSortNb = true;
 
2249
 
 
2250
                        do {
 
2251
                                m_faMinMaxDist.Add(AskFloat("    Enter the minimal distance in pm: [0] ",0.0f));
 
2252
                                m_faMinMaxDist.Add(AskFloat("    Enter the maximal distance in pm: [400] ",400.0f));
 
2253
                        } while (AskYesNo("    Enter another distance interval (y/n)? [no] ",false));
 
2254
                        n->m_iNbCountMin = -1;
 
2255
                        n->m_iNbCountMax = -1;
 
2256
                } else
 
2257
                {
 
2258
                        n->m_iNbCountMin = AskRangeInteger("    Use next neighbors from the n-th on? [1] ",0,((CMolecule*)g_oaMolecules[m_iShowMol])->m_laSingleMolIndex.GetSize(),1)-1;
 
2259
                        n->m_iNbCountMax = AskRangeInteger("    Use next neighbors up to the n-th? [%d] ",n->m_iNbCountMin+1,((CMolecule*)g_oaMolecules[m_iShowMol])->m_laSingleMolIndex.GetSize(),n->m_iNbCountMin+1,n->m_iNbCountMin+1)-1;
 
2260
//                      m_faMinMaxDist.Add(0);
 
2261
//                      m_faMinMaxDist.Add(9E20f);
 
2262
                }
 
2263
        } else
 
2264
        {
 
2265
                m_faMinMaxDist.Add(0);
 
2266
                m_faMinMaxDist.Add(1.0e30f);
 
2267
                n->m_iNbCountMin = -2;
 
2268
                n->m_iNbCountMax = -2;
 
2269
        }
 
2270
        mprintf(WHITE,"\n<<< End of Distance Condition <<<\n\n");
 
2271
        BTOUT;
 
2272
}
 
2273
 
 
2274
 
 
2275
void CRDF::ParseConditionGrid(int rm, CNbSearch *n, int gridmode)
 
2276
{
 
2277
        BTIN;
 
2278
        char buf[256];
 
2279
        int ti;
 
2280
        CAtomGroup *ag;
 
2281
 
 
2282
        try { m_pRDF = new CDF(); } catch(...) { m_pRDF = NULL; }
 
2283
        if (m_pRDF == NULL) NewException((double)sizeof(CDF),__FILE__,__LINE__,__PRETTY_FUNCTION__);
 
2284
        
 
2285
        m_iShowAtomGes = 0;
 
2286
        m_iRefAtomGes = 0;
 
2287
        m_iCombinations = 0;
 
2288
        m_iRefOrSec[0] = 0;
 
2289
        m_iRefOrSec[1] = 1;
 
2290
        mprintf(WHITE,"\n>>> Distance Condition >>>\n");
 
2291
 
 
2292
_rdfnewset:
 
2293
        mprintf("\n");
 
2294
 
 
2295
        try { ag = new CAtomGroup(); } catch(...) { ag = NULL; }
 
2296
        if (ag == NULL) NewException((double)sizeof(CAtomGroup),__FILE__,__LINE__,__PRETTY_FUNCTION__);
 
2297
 
 
2298
_rdfatom1:
 
2299
        if (((CMolecule*)g_oaMolecules[rm])->m_iAtomGes == 3)
 
2300
        {
 
2301
                mprintf("    %s is only one atom, there is no choice.\n",((CMolecule*)g_oaMolecules[rm])->m_sName);
 
2302
                ag->Reset();
 
2303
                ag->m_pMolecule = (CMolecule*)g_oaMolecules[rm];
 
2304
                ag->AddAtom(0,0,false);
 
2305
                ag->SortAtoms();
 
2306
                ag->BuildName();
 
2307
        } else
 
2308
        {
 
2309
                mprintf("    Which atom(s) to take from RM %s (e.g. \"C1,C3-5,H\", \"*\"=all)? [#2] ",((CMolecule*)g_oaMolecules[rm])->m_sName);
 
2310
                inpprintf("! Which atom(s) to take from RM %s (e.g. \"C1,C3-5,H\", \"*\"=all)? [#2]\n",((CMolecule*)g_oaMolecules[rm])->m_sName);
 
2311
                myget(buf);
 
2312
                if (strlen(buf) == 0)
 
2313
                {
 
2314
                        if (!ag->ParseAtoms((CMolecule*)g_oaMolecules[rm],"#2"))
 
2315
                        {
 
2316
                                eprintf("Weird error.\n");
 
2317
                                goto _rdfatom1;
 
2318
                        }
 
2319
                } else if (!ag->ParseAtoms((CMolecule*)g_oaMolecules[rm],buf))
 
2320
                        goto _rdfatom1;
 
2321
        }
 
2322
        m_oaVectors.Add(ag);
 
2323
        m_iRefAtomGes += ag->m_iAtomGes;
 
2324
        ti = ag->m_iAtomGes;
 
2325
 
 
2326
        try { ag = new CAtomGroup(); } catch(...) { ag = NULL; }
 
2327
        if (ag == NULL) NewException((double)sizeof(CAtomGroup),__FILE__,__LINE__,__PRETTY_FUNCTION__);
 
2328
 
 
2329
_rdfatom2:
 
2330
        if (((CMolecule*)g_oaMolecules[m_iShowMol])->m_iAtomGes == 3)
 
2331
        {
 
2332
                mprintf("    %s is only one atom, there is no choice.\n",((CMolecule*)g_oaMolecules[m_iShowMol])->m_sName);
 
2333
                ag->Reset();
 
2334
                ag->m_pMolecule = (CMolecule*)g_oaMolecules[m_iShowMol];
 
2335
                ag->AddAtom(0,0,false);
 
2336
                ag->SortAtoms();
 
2337
                ag->BuildName();
 
2338
        } else
 
2339
        {
 
2340
                mprintf("    Which atom(s) to take from OM %s (e.g. \"C1,C3-5,H\", \"*\"=all)? [#2] ",((CMolecule*)g_oaMolecules[m_iShowMol])->m_sName);
 
2341
                inpprintf("! Which atom(s) to take from OM %s (e.g. \"C1,C3-5,H\", \"*\"=all)? [#2]\n",((CMolecule*)g_oaMolecules[m_iShowMol])->m_sName);
 
2342
                myget(buf);
 
2343
 
 
2344
                try { ag = new CAtomGroup(); } catch(...) { ag = NULL; }
 
2345
                if (ag == NULL) NewException((double)sizeof(CAtomGroup),__FILE__,__LINE__,__PRETTY_FUNCTION__);
 
2346
 
 
2347
                if (strlen(buf) == 0)
 
2348
                {
 
2349
                        if (!ag->ParseAtoms((CMolecule*)g_oaMolecules[m_iShowMol],"#2"))
 
2350
                        {
 
2351
                                eprintf("Weird error.\n");
 
2352
                                goto _rdfatom2;
 
2353
                        }
 
2354
                } else if (!ag->ParseAtoms((CMolecule*)g_oaMolecules[m_iShowMol],buf))
 
2355
                        goto _rdfatom2;
 
2356
        }
 
2357
        m_oaVectors.Add(ag);
 
2358
        m_iShowAtomGes += ag->m_iAtomGes;
 
2359
        m_iCombinations += ti * ag->m_iAtomGes;
 
2360
 
 
2361
        if (AskYesNo("    Enter another set of atoms (y/n)? [no] ",false))
 
2362
                goto _rdfnewset;
 
2363
 
 
2364
        if (gridmode == 6)
 
2365
        {
 
2366
                if (AskUnsignedInteger("\n    Enter min./max. distance (0) or min./max. nearest neighbor count (1)? [0] ",0)==0)
 
2367
                {
 
2368
                        m_faMinMaxDist.Add(AskFloat("    Enter the minimal distance in pm: [0] ",0.0f));
 
2369
                        m_faMinMaxDist.Add(AskFloat("    Enter the maximal distance in pm: [400] ",400.0f));
 
2370
                        n->m_iNbCountMin = -1;
 
2371
                        n->m_iNbCountMax = -1;
 
2372
                } else
 
2373
                {
 
2374
                        n->m_iNbCountMin = AskRangeInteger("    Use next neighbors from the n-th on? [1] ",0,((CMolecule*)g_oaMolecules[m_iShowMol])->m_laSingleMolIndex.GetSize(),1)-1;
 
2375
                        n->m_iNbCountMax = AskRangeInteger("    Use next neighbors up to the n-th? [%d] ",n->m_iNbCountMin+1,((CMolecule*)g_oaMolecules[m_iShowMol])->m_laSingleMolIndex.GetSize(),n->m_iNbCountMin+1,n->m_iNbCountMin+1)-1;
 
2376
//                      m_faMinMaxDist.Add(0);
 
2377
//                      m_faMinMaxDist.Add(9E20f);
 
2378
                }
 
2379
        } else if ((gridmode == 4) || (gridmode == 5))
 
2380
        {
 
2381
                n->m_iNbCountMin = 0;
 
2382
                n->m_iNbCountMax = 0;
 
2383
//              m_faMinMaxDist.Add(0);
 
2384
//              m_faMinMaxDist.Add(9E20f);
 
2385
        } else if (gridmode == 2)
 
2386
        {
 
2387
                m_faMinMaxDist.Add(AskFloat("    Enter the minimal distance in pm: [0] ",0.0f));
 
2388
                m_faMinMaxDist.Add(AskFloat("    Enter the maximal distance in pm: [400] ",400.0f));
 
2389
                n->m_iNbCountMin = -1;
 
2390
                n->m_iNbCountMax = -1;
 
2391
        } else 
 
2392
        {
 
2393
                m_faMinMaxDist.Add(0.0f);
 
2394
                m_faMinMaxDist.Add(400.0f);
 
2395
                n->m_iNbCountMin = -1;
 
2396
                n->m_iNbCountMax = -1;
 
2397
        }
 
2398
        mprintf(WHITE,"\n<<< End of Distance Condition <<<\n\n");
 
2399
        BTOUT;
 
2400
}
 
2401
 
 
2402
 
 
2403
void CRDF::ParseCondition_OnlyValues(CNbSearch *n)
 
2404
{
 
2405
        BTIN;
 
2406
        int z;
 
2407
 
 
2408
        mprintf("    Distance condition between ");
 
2409
        for (z=0;z<m_oaVectors.GetSize()/2;z++)
 
2410
        {
 
2411
                mprintf("%s and %s",((CAtomGroup*)m_oaVectors[z*2])->m_sName,((CAtomGroup*)m_oaVectors[z*2+1])->m_sName);
 
2412
                if (z < (m_oaVectors.GetSize()/2)-1)
 
2413
                        mprintf(", ");
 
2414
        }
 
2415
        mprintf("\n");
 
2416
        if (n->m_iNbCountMin == -1)
 
2417
        {
 
2418
                for (z=0;z<m_faMinMaxDist.GetSize()/2;z++)
 
2419
                {
 
2420
                        mprintf("    Interval %d:\n",z+1,m_faMinMaxDist.GetSize()/2);
 
2421
                        m_faMinMaxDist[z*2] = AskFloat("      Enter the minimal distance in pm: [0] ",0.0f);
 
2422
                        m_faMinMaxDist[z*2+1] = AskFloat("      Enter the maximal distance in pm: [400] ",400.0f);
 
2423
                }
 
2424
        } else
 
2425
        {
 
2426
                n->m_iNbCountMin = AskRangeInteger("    Use next neighbors from the n-th on? [1] ",0,((CMolecule*)g_oaMolecules[m_iShowMol])->m_laSingleMolIndex.GetSize(),1)-1;
 
2427
                n->m_iNbCountMax = AskRangeInteger("    Use next neighbors up to the n-th? [%d] ",n->m_iNbCountMin+1,((CMolecule*)g_oaMolecules[m_iShowMol])->m_laSingleMolIndex.GetSize(),n->m_iNbCountMin+1,n->m_iNbCountMin+1)-1;
 
2428
        }
 
2429
 
 
2430
        BTOUT;
 
2431
}
 
2432
 
 
2433
 
 
2434
void CVHDF::Parse()
 
2435
{
 
2436
        BTIN;
 
2437
        char buf[256];
 
2438
        int ti;
 
2439
        CAtomGroup *ag;
 
2440
 
 
2441
        try { m_pVHDF = new C2DF(); } catch(...) { m_pVHDF = NULL; }
 
2442
        if (m_pVHDF == NULL) NewException((double)sizeof(C2DF),__FILE__,__LINE__,__PRETTY_FUNCTION__);
 
2443
        
 
2444
        m_iShowAtomGes = 0;
 
2445
        m_iRefAtomGes = 0;
 
2446
        m_iCombinations = 0;
 
2447
        mprintf(WHITE,"\n>>> Van Hove Correlation Function >>>\n\n");
 
2448
        if (m_iShowMol != -1)
 
2449
        {
 
2450
                m_iRefOrSec[0] = AskRangeInteger("    Take (fixed) reference atom(s) from RM %s (0) or from OM %s (1)? [0] ",0,1,0,((CMolecule*)g_oaMolecules[g_iFixMol])->m_sName,((CMolecule*)g_oaMolecules[m_iShowMol])->m_sName);
 
2451
                m_iRefOrSec[1] = AskRangeInteger("    Take (moving) observed atom(s) from RM %s (0) or from OM %s (1)? [1] ",0,1,1,((CMolecule*)g_oaMolecules[g_iFixMol])->m_sName,((CMolecule*)g_oaMolecules[m_iShowMol])->m_sName);
 
2452
        } else // Kein OM: Nimm alles aus RM
 
2453
        {
 
2454
                m_iRefOrSec[0] = 0;
 
2455
                m_iRefOrSec[1] = 0;
 
2456
        }
 
2457
_rdfnewset:
 
2458
        mprintf("\n");
 
2459
 
 
2460
        try { ag = new CAtomGroup(); } catch(...) { ag = NULL; }
 
2461
        if (ag == NULL) NewException((double)sizeof(CAtomGroup),__FILE__,__LINE__,__PRETTY_FUNCTION__);
 
2462
 
 
2463
_rdfatom1:
 
2464
        if (m_iRefOrSec[0])
 
2465
        {
 
2466
                mprintf("    Which (fixed) reference atom(s) to take from OM %s (e.g. \"C1,C3-5,H\", \"*\"=all)? [#2] ",((CMolecule*)g_oaMolecules[m_iShowMol])->m_sName);
 
2467
                inpprintf("! Which (fixed) reference atom(s) to take from OM %s (e.g. \"C1,C3-5,H\", \"*\"=all)? [#2]\n",((CMolecule*)g_oaMolecules[m_iShowMol])->m_sName);
 
2468
        } else
 
2469
        {
 
2470
                mprintf("    Which (fixed) reference atom(s) to take from RM %s (e.g. \"C1,C3-5,H\", \"*\"=all)? [#2] ",((CMolecule*)g_oaMolecules[g_iFixMol])->m_sName);
 
2471
                inpprintf("! Which (fixed) reference atom(s) to take from RM %s (e.g. \"C1,C3-5,H\", \"*\"=all)? [#2]\n",((CMolecule*)g_oaMolecules[g_iFixMol])->m_sName);
 
2472
        }
 
2473
        myget(buf);
 
2474
        if (strlen(buf) == 0)
 
2475
        {
 
2476
                if (!ag->ParseAtoms((CMolecule*)g_oaMolecules[(m_iRefOrSec[0])?m_iShowMol:g_iFixMol],"#2"))
 
2477
                        goto _rdfatom1;
 
2478
        } else if (!ag->ParseAtoms((CMolecule*)g_oaMolecules[(m_iRefOrSec[0])?m_iShowMol:g_iFixMol],buf))
 
2479
                goto _rdfatom1;
 
2480
        m_oaVectors.Add(ag);
 
2481
        m_iRefAtomGes += ag->m_iAtomGes;
 
2482
        ti = ag->m_iAtomGes;
 
2483
 
 
2484
        try { ag = new CAtomGroup(); } catch(...) { ag = NULL; }
 
2485
        if (ag == NULL) NewException((double)sizeof(CAtomGroup),__FILE__,__LINE__,__PRETTY_FUNCTION__);
 
2486
 
 
2487
_rdfatom2:
 
2488
        if (m_iRefOrSec[1])
 
2489
        {
 
2490
                mprintf("    Which (moving) observed atom(s) to take from OM %s (e.g. \"C1,C3-5,H\", \"*\"=all)? [#2] ",((CMolecule*)g_oaMolecules[m_iShowMol])->m_sName);
 
2491
                inpprintf("! Which (moving) observed atom(s) to take from OM %s (e.g. \"C1,C3-5,H\", \"*\"=all)? [#2]\n",((CMolecule*)g_oaMolecules[m_iShowMol])->m_sName);
 
2492
        } else
 
2493
        {
 
2494
                mprintf("    Which (moving) observed atom(s) to take from RM %s (e.g. \"C1,C3-5,H\", \"*\"=all)? [#2] ",((CMolecule*)g_oaMolecules[g_iFixMol])->m_sName);
 
2495
                inpprintf("! Which (moving) observed atom(s) to take from RM %s (e.g. \"C1,C3-5,H\", \"*\"=all)? [#2]\n",((CMolecule*)g_oaMolecules[g_iFixMol])->m_sName);
 
2496
        }
 
2497
        myget(buf);
 
2498
 
 
2499
        try { ag = new CAtomGroup(); } catch(...) { ag = NULL; }
 
2500
        if (ag == NULL) NewException((double)sizeof(CAtomGroup),__FILE__,__LINE__,__PRETTY_FUNCTION__);
 
2501
 
 
2502
        if (strlen(buf) == 0)
 
2503
        {
 
2504
                if (!ag->ParseAtoms((CMolecule*)g_oaMolecules[(m_iRefOrSec[1])?m_iShowMol:g_iFixMol],"#2"))
 
2505
                        goto _rdfatom2;
 
2506
        } else if (!ag->ParseAtoms((CMolecule*)g_oaMolecules[(m_iRefOrSec[1])?m_iShowMol:g_iFixMol],buf))
 
2507
                goto _rdfatom2;
 
2508
        m_oaVectors.Add(ag);
 
2509
        m_iShowAtomGes += ag->m_iAtomGes;
 
2510
        m_iCombinations += ti * ag->m_iAtomGes;
 
2511
 
 
2512
        if (g_bAdvanced2)
 
2513
                if (AskYesNo("    Enter another set of atoms (y/n)? [no] ",false))
 
2514
                        goto _rdfnewset;
 
2515
 
 
2516
        m_fMinDist = 0; //AskFloat("    Enter the minimal radius of this VHCF in pm: [0] ",0.0f);
 
2517
        m_fMaxDist = AskFloat("    Enter the radius of this VHCF in pm: [%d.0] ",(float)HalfBox(),HalfBox());
 
2518
        m_iResolution = AskUnsignedInteger("    Enter the radial resolution of this VHCF: [100] ",100);
 
2519
        m_bRadialCorrect = AskYesNo("    Correct radial distribution for this VHCF (y/n)? [%s] ",!m_bSelf,m_bSelf?"no":"yes");
 
2520
 
 
2521
_depth:
 
2522
        if (g_iTrajSteps != -1)
 
2523
                m_iDepth = AskUnsignedInteger("    Enter the temporal resolution (time depth) of this VHCF (in time steps): [%d] ",int(g_iTrajSteps*0.75),int(g_iTrajSteps*0.75));
 
2524
                        else m_iDepth = AskUnsignedInteger("    Enter the temporal resolution (time depth) of this VHCF (in time steps): [5000] ",5000);
 
2525
 
 
2526
        mprintf("\n    This will occupy %s of RAM.\n",FormatBytes((double)m_iDepth*g_iGesVirtAtomCount*3.0*sizeof(float)));
 
2527
        if (m_iDepth*g_iGesVirtAtomCount*3.0*sizeof(float)/1024.0f/1024.0f >= 1000.0f)
 
2528
                if (!AskYesNo("    Make sure that enough free RAM is available. Continue (y/n)? [yes] ",true))
 
2529
                        goto _depth;
 
2530
        mprintf("\n");
 
2531
 
 
2532
_resagain:
 
2533
        m_iStride = AskUnsignedInteger("    Take each n-th time step for the temporal axis? [%d] ",max(1,m_iDepth/100),max(1,m_iDepth/100));
 
2534
 
 
2535
        mprintf("\n    This results in a plot resolution of %d on the temporal axis.\n",m_iDepth/m_iStride);
 
2536
 
 
2537
        if (m_iDepth/m_iStride > 200)
 
2538
        {
 
2539
                mprintf("\n");
 
2540
                if (!AskYesNo("    The resolution seems quite high, the plot will take much time to render. Contiune (y/n)? [yes] ",true))
 
2541
                        goto _resagain;
 
2542
        }
 
2543
 
 
2544
        if (g_bAdvanced2)
 
2545
        {
 
2546
                mprintf("\n");
 
2547
                m_bSwapAxes = AskYesNo("    Put distance on X axis and time on Y axis (y) or swap axes (n)? [yes] ",true);
 
2548
                m_iGraceBunchTime = AskUnsignedInteger("    How many time graphs do you want do draw in the distance grace stack (0=disable)? [10] ",10);
 
2549
                m_iGraceBunchDist = AskUnsignedInteger("    How many distance graphs do you want do draw in the time grace stack (0=disable)? [10] ",10);
 
2550
        } else
 
2551
        {
 
2552
                m_bSwapAxes = true;
 
2553
                m_iGraceBunchTime = 0;
 
2554
                m_iGraceBunchDist = 0;
 
2555
        }
 
2556
 
 
2557
        BuildName();
 
2558
        mprintf(WHITE,"\n<<< End of Van Hove Correlation Function <<<\n\n");
 
2559
        BTOUT;
 
2560
}
 
2561
 
 
2562
 
 
2563
void CADF::Parse()
 
2564
{
 
2565
        BTIN;
 
2566
        char buf[256];
 
2567
        int z, z2, ti;
 
2568
        CAtomGroup *ag;
 
2569
        float tf;
 
2570
 
 
2571
        try { m_pADF = new CDF(); } catch(...) { m_pADF = NULL; }
 
2572
        if (m_pADF == NULL) NewException((double)sizeof(CDF),__FILE__,__LINE__,__PRETTY_FUNCTION__);
 
2573
        
 
2574
        mprintf(WHITE,"\n>>> Angular Distribution Function >>>\n\n");
 
2575
        for (z=0;z<2;z++)
 
2576
        {
 
2577
                m_iVecType[z] = AskRangeInteger("    Should the %d. vector depict position (1), dipole (2), velocity (3) or force (4)? [1] ",1,4,1,z+1) - 1;
 
2578
                if (m_iVecType[z] == 1)
 
2579
                {
 
2580
                        g_bDipole = true;
 
2581
                        ParseDipole();
 
2582
                }
 
2583
        }
 
2584
        z2 = 0;
 
2585
        m_iCombinations = 0;
 
2586
        do {
 
2587
                ti = 1;
 
2588
                if (z2 != 0)
 
2589
                        mprintf("\n    %d. set of vectors\n\n",z2+1);
 
2590
                for (z=0;z<2;z++)
 
2591
                {
 
2592
                        if (m_iVecType[z] == 0) // Position
 
2593
                        {
 
2594
/*                              if (z2 == 0)
 
2595
                                        if ((z == 1) && (m_iVecType[0] == 0) && (m_iVecType[1] == 0))
 
2596
                                                m_bSameFoot = AskYesNo("    Should the base points of the 1st and 2nd vectors always be equal (y/n)? [no] ",false);
 
2597
                                                        else m_bSameFoot = false;*/
 
2598
 
 
2599
                                if (z2 == 0)
 
2600
                                        m_bOrtho[z] = (AskRangeInteger("\n    Should the %d. vector connect 2 points (0) or stand perpendicular to 3 points (1)? [0] ",0,1,0,z+1) != 0);
 
2601
 
 
2602
                                mprintf("\n");
 
2603
                                if (m_bOrtho[z])
 
2604
                                {
 
2605
/*                                      if (m_bSameFoot && (z == 1))
 
2606
                                        {
 
2607
                                                m_iRefOrSec[1][0] = m_iRefOrSec[0][0];
 
2608
                                                m_oaVectors.Add(NULL);
 
2609
                                        } else*/
 
2610
                                        {
 
2611
_ax1:                                   if (z2 == 0)
 
2612
                                                {
 
2613
                                                        if (m_iShowMol != -1)
 
2614
                                                                m_iRefOrSec[z][0] = AskRangeInteger("    Take atom(s) at the base point from RM %s (0) or from OM %s (1)? [%d] ",0,1,z,((CMolecule*)g_oaMolecules[g_iFixMol])->m_sName,((CMolecule*)g_oaMolecules[m_iShowMol])->m_sName,z);
 
2615
                                                                        else m_iRefOrSec[z][0] = 0;
 
2616
                                                }
 
2617
                                                mprintf("      Please enter the atom(s) at the base point (e.g. C7): ");
 
2618
                                                inpprintf("! Please enter the atom(s) at the base point (e.g. C7):\n");
 
2619
                                                myget(buf);
 
2620
 
 
2621
                                                try { ag = new CAtomGroup(); } catch(...) { ag = NULL; }
 
2622
                                                if (ag == NULL) NewException((double)sizeof(CAtomGroup),__FILE__,__LINE__,__PRETTY_FUNCTION__);
 
2623
 
 
2624
                                                if (!ag->ParseAtoms((!m_iRefOrSec[z][0])?(CMolecule*)g_oaMolecules[g_iFixMol]:(CMolecule*)g_oaMolecules[m_iShowMol],buf))
 
2625
                                                {
 
2626
                                                        eprintf("Wrong input.\n");
 
2627
                                                        inpprintf("! Wrong input.\n");
 
2628
                                                        delete ag;
 
2629
                                                        goto _ax1;
 
2630
                                                }
 
2631
                                                m_oaVectors.Add(ag);
 
2632
                                                ti *= ag->m_iAtomGes;
 
2633
                                        }
 
2634
_ax2:                           if (z2 == 0)
 
2635
                                        {
 
2636
                                                if (m_iShowMol != -1)
 
2637
                                                        m_iRefOrSec[z][1] = AskRangeInteger("    Take 2nd atom(s) of normal plane from RM %s (0) or from OM %s (1)? [%d] ",0,1,z,((CMolecule*)g_oaMolecules[g_iFixMol])->m_sName,((CMolecule*)g_oaMolecules[m_iShowMol])->m_sName,z);
 
2638
                                                                else m_iRefOrSec[z][1] = 0;
 
2639
                                        }
 
2640
                                        mprintf("      Please enter the 2nd atom(s) of the normal plane (e.g. C7): ");
 
2641
                                        inpprintf("! Please enter the 2nd atom(s) of the normal plane (e.g. C7):\n");
 
2642
                                        myget(buf);
 
2643
 
 
2644
                                        try { ag = new CAtomGroup(); } catch(...) { ag = NULL; }
 
2645
                                        if (ag == NULL) NewException((double)sizeof(CAtomGroup),__FILE__,__LINE__,__PRETTY_FUNCTION__);
 
2646
 
 
2647
                                        if (!ag->ParseAtoms((!m_iRefOrSec[z][1])?(CMolecule*)g_oaMolecules[g_iFixMol]:(CMolecule*)g_oaMolecules[m_iShowMol],buf))
 
2648
                                        {
 
2649
                                                eprintf("Wrong input.\n");
 
2650
                                                inpprintf("! Wrong input.\n");
 
2651
                                                delete ag;
 
2652
                                                goto _ax2;
 
2653
                                        }
 
2654
                                        m_oaVectors.Add(ag);
 
2655
                                        ti *= ag->m_iAtomGes;
 
2656
_ax3:                           if (z2 == 0)
 
2657
                                        {
 
2658
                                                if (m_iShowMol != -1)
 
2659
                                                        m_iRefOrSec[z][2] = AskRangeInteger("    Take 3rd atom(s) of normal plane from RM %s (0) or from OM %s (1)? [%d] ",0,1,z,((CMolecule*)g_oaMolecules[g_iFixMol])->m_sName,((CMolecule*)g_oaMolecules[m_iShowMol])->m_sName,z);
 
2660
                                                                else m_iRefOrSec[z][2] = 0;
 
2661
                                        }
 
2662
                                        mprintf("      Please enter the 3rd atom(s) of the normal plane (e.g. C7): ");
 
2663
                                        inpprintf("! Please enter the 3rd atom(s) of the normal plane (e.g. C7):\n");
 
2664
                                        myget(buf);
 
2665
 
 
2666
                                        try { ag = new CAtomGroup(); } catch(...) { ag = NULL; }
 
2667
                                        if (ag == NULL) NewException((double)sizeof(CAtomGroup),__FILE__,__LINE__,__PRETTY_FUNCTION__);
 
2668
 
 
2669
                                        if (!ag->ParseAtoms((!m_iRefOrSec[z][2])?(CMolecule*)g_oaMolecules[g_iFixMol]:(CMolecule*)g_oaMolecules[m_iShowMol],buf))
 
2670
                                        {
 
2671
                                                eprintf("Wrong input.\n");
 
2672
                                                inpprintf("! Wrong input.\n");
 
2673
                                                delete ag;
 
2674
                                                goto _ax3;
 
2675
                                        }
 
2676
                                        m_oaVectors.Add(ag);
 
2677
                                        ti *= ag->m_iAtomGes;
 
2678
                                } else // IF ORTHO
 
2679
                                {
 
2680
/*                                      if (m_bSameFoot && (z == 1))
 
2681
                                        {
 
2682
                                                m_iRefOrSec[1][0] = m_iRefOrSec[0][0];
 
2683
                                                m_oaVectors.Add(NULL);
 
2684
                                        } else*/
 
2685
                                        {
 
2686
_ax4:                                   if (z2 == 0)
 
2687
                                                {
 
2688
                                                        if (m_iShowMol != -1)
 
2689
                                                                m_iRefOrSec[z][0] = AskRangeInteger("    Take atom(s) at the base point from RM %s (0) or from OM %s (1)? [%d] ",0,1,z,((CMolecule*)g_oaMolecules[g_iFixMol])->m_sName,((CMolecule*)g_oaMolecules[m_iShowMol])->m_sName,z);
 
2690
                                                                        else m_iRefOrSec[z][0] = 0;
 
2691
                                                }
 
2692
                                                mprintf("      Please enter the atom(s) at the base point (e.g. C7): ");
 
2693
                                                inpprintf("! Please enter the atom(s) at the base point (e.g. C7):\n");
 
2694
                                                myget(buf);
 
2695
 
 
2696
                                                try { ag = new CAtomGroup(); } catch(...) { ag = NULL; }
 
2697
                                                if (ag == NULL) NewException((double)sizeof(CAtomGroup),__FILE__,__LINE__,__PRETTY_FUNCTION__);
 
2698
 
 
2699
                                                if (!ag->ParseAtoms((!m_iRefOrSec[z][0])?(CMolecule*)g_oaMolecules[g_iFixMol]:(CMolecule*)g_oaMolecules[m_iShowMol],buf))
 
2700
                                                {
 
2701
                                                        eprintf("Wrong input.\n");
 
2702
                                                        inpprintf("! Wrong input.\n");
 
2703
                                                        delete ag;
 
2704
                                                        goto _ax4;
 
2705
                                                }
 
2706
                                                m_oaVectors.Add(ag);
 
2707
                                                ti *= ag->m_iAtomGes;
 
2708
                                        } // END IF NOT SAMEFOOT
 
2709
_ax5:                           if (z2 == 0)
 
2710
                                        {
 
2711
                                                if (m_iShowMol != -1)
 
2712
                                                        m_iRefOrSec[z][1] = AskRangeInteger("    Take atom(s) at the tip point from RM %s (0) or from OM %s (1)? [%d] ",0,1,z,((CMolecule*)g_oaMolecules[g_iFixMol])->m_sName,((CMolecule*)g_oaMolecules[m_iShowMol])->m_sName,z);
 
2713
                                                                else m_iRefOrSec[z][1] = 0;
 
2714
                                        }
 
2715
                                        mprintf("      Please enter the atom(s) at the tip point (e.g. C7): ");
 
2716
                                        inpprintf("! Please enter the atom(s) at the tip point (e.g. C7):\n");
 
2717
                                        myget(buf);
 
2718
 
 
2719
                                        try { ag = new CAtomGroup(); } catch(...) { ag = NULL; }
 
2720
                                        if (ag == NULL) NewException((double)sizeof(CAtomGroup),__FILE__,__LINE__,__PRETTY_FUNCTION__);
 
2721
 
 
2722
                                        if (!ag->ParseAtoms((!m_iRefOrSec[z][1])?(CMolecule*)g_oaMolecules[g_iFixMol]:(CMolecule*)g_oaMolecules[m_iShowMol],buf))
 
2723
                                        {
 
2724
                                                eprintf("Wrong input.\n");
 
2725
                                                inpprintf("! Wrong input.\n");
 
2726
                                                delete ag;
 
2727
                                                goto _ax5;
 
2728
                                        }
 
2729
                                        m_oaVectors.Add(ag);
 
2730
                                        ti *= ag->m_iAtomGes;
 
2731
                                        m_oaVectors.Add(NULL);
 
2732
                                } // END IF NOT ORTHO
 
2733
                        } else if (m_iVecType[z] == 1) // Dipol
 
2734
                        {
 
2735
                                if (m_iShowMol != -1)
 
2736
                                        m_iRefOrSec[z][0] = AskRangeInteger("    Take dipole vector from RM %s (0) or from OM %s (1)? [%d] ",0,1,z,((CMolecule*)g_oaMolecules[g_iFixMol])->m_sName,((CMolecule*)g_oaMolecules[m_iShowMol])->m_sName,z);
 
2737
                                                else m_iRefOrSec[z][0] = 0;
 
2738
                        } else if (m_iVecType[z] == 2) // Geschwindigkeit
 
2739
                        {
 
2740
_ax6:                   if (m_iShowMol != -1)
 
2741
                                        m_iRefOrSec[z][0] = AskRangeInteger("    Take velocity vector from RM %s (0) or from OM %s (1)? [%d] ",0,1,z,((CMolecule*)g_oaMolecules[g_iFixMol])->m_sName,((CMolecule*)g_oaMolecules[m_iShowMol])->m_sName,z);
 
2742
                                                else m_iRefOrSec[z][0] = 0;
 
2743
                                mprintf("      Velocity vector of which atoms to use (e.g. C7)? [#2] ");
 
2744
                                inpprintf("! Velocity vector of which atoms to use (e.g. C7)? [#2]\n");
 
2745
                                myget(buf);
 
2746
 
 
2747
                                try { ag = new CAtomGroup(); } catch(...) { ag = NULL; }
 
2748
                                if (ag == NULL) NewException((double)sizeof(CAtomGroup),__FILE__,__LINE__,__PRETTY_FUNCTION__);
 
2749
 
 
2750
                                if (strlen(buf)==0)
 
2751
                                {
 
2752
                                        if (!ag->ParseAtoms((!m_iRefOrSec[z][0])?(CMolecule*)g_oaMolecules[g_iFixMol]:(CMolecule*)g_oaMolecules[m_iShowMol],"#2"))
 
2753
                                        {
 
2754
                                                eprintf("Weird error.\n");
 
2755
                                                inpprintf("! Weird error.\n");
 
2756
                                                abort();
 
2757
                                        }
 
2758
                                } else if (!ag->ParseAtoms((!m_iRefOrSec[z][0])?(CMolecule*)g_oaMolecules[g_iFixMol]:(CMolecule*)g_oaMolecules[m_iShowMol],buf))
 
2759
                                {
 
2760
                                        eprintf("Wrong input.\n");
 
2761
                                        inpprintf("! Wrong input.\n");
 
2762
                                        delete ag;
 
2763
                                        goto _ax6;
 
2764
                                }
 
2765
                                m_oaVectors.Add(ag);
 
2766
                                ti *= ag->m_iAtomGes;
 
2767
                        } else if (m_iVecType[z] == 3) // Kraft
 
2768
                        {
 
2769
_ax7:                   if (m_iShowMol != -1)
 
2770
                                        m_iRefOrSec[z][0] = AskRangeInteger("    Take force vektor from RM %s (0) or from OM %s (1)? [%d] ",0,1,z,((CMolecule*)g_oaMolecules[g_iFixMol])->m_sName,((CMolecule*)g_oaMolecules[m_iShowMol])->m_sName,z);
 
2771
                                                else m_iRefOrSec[z][0] = 0;
 
2772
                                mprintf("      Force vector of which atoms to use (e.g. C7)? [#2] ");
 
2773
                                inpprintf("! Force vector of which atoms to use (e.g. C7)? [#2]\n");
 
2774
                                myget(buf);
 
2775
 
 
2776
                                try { ag = new CAtomGroup(); } catch(...) { ag = NULL; }
 
2777
                                if (ag == NULL) NewException((double)sizeof(CAtomGroup),__FILE__,__LINE__,__PRETTY_FUNCTION__);
 
2778
 
 
2779
                                if (strlen(buf)==0)
 
2780
                                {
 
2781
                                        if (!ag->ParseAtoms((!m_iRefOrSec[z][0])?(CMolecule*)g_oaMolecules[g_iFixMol]:(CMolecule*)g_oaMolecules[m_iShowMol],"#2"))
 
2782
                                        {
 
2783
                                                eprintf("Weird Error.\n");
 
2784
                                                inpprintf("! Weird Error.\n");
 
2785
                                                abort();
 
2786
                                        }
 
2787
                                } else if (!ag->ParseAtoms((!m_iRefOrSec[z][0])?(CMolecule*)g_oaMolecules[g_iFixMol]:(CMolecule*)g_oaMolecules[m_iShowMol],buf))
 
2788
                                {
 
2789
                                        eprintf("Wrong input.\n");
 
2790
                                        inpprintf("! Wrong input.\n");
 
2791
                                        delete ag;
 
2792
                                        goto _ax7;
 
2793
                                }
 
2794
                                m_oaVectors.Add(ag);
 
2795
                                ti *= ag->m_iAtomGes;
 
2796
                        }
 
2797
                } // END FOR 0..1
 
2798
                z2++;
 
2799
                m_iCombinations += ti;
 
2800
        } while (g_bAdvanced2?AskYesNo("\n    Add another set of vectors to this (!) ADF (y/n)? [no] ",false):false);
 
2801
 
 
2802
        ParseDeriv();
 
2803
 
 
2804
        switch(m_iDeriv)
 
2805
        {
 
2806
                case 0:
 
2807
                        mprintf("\n");
 
2808
_anglowag:
 
2809
                        m_fMinAngle = AskFloat("    Enter minimal angle between the vectors: [0 deg] ",0.0f);
 
2810
                        if (m_fMinAngle < 0)
 
2811
                        {
 
2812
                                eprintf("    Angles < 0 degree are not defined.\n");
 
2813
                                goto _anglowag;
 
2814
                        }
 
2815
                        m_fMaxAngle = AskFloat("    Enter maximal angle between the vectors: [180 deg] ",180.0f);
 
2816
                        break;
 
2817
                case 1:
 
2818
                        if (m_bDerivAbs)
 
2819
                                m_fMinAngle = AskFloat("    Enter the minimal value of this d1-ADF in deg/ps: [0] ",0.0f);
 
2820
                                        else m_fMinAngle = AskFloat("    Enter the minimal value of this d1-ADF in deg/ps: [-10.0] ",-10.0f);
 
2821
                        m_fMaxAngle = AskFloat("    Enter the maximal value of this d1-ADF in deg/ps: [10.0] ",10.0f);
 
2822
                        break;
 
2823
                case 2:
 
2824
                        if (m_bDerivAbs)
 
2825
                                m_fMinAngle = AskFloat("    Enter the minimal value of this d2-ADF in deg/ps^2: [0] ",0.0f);
 
2826
                                        else m_fMinAngle = AskFloat("    Enter the minimal value of this d2-ADF in deg/ps^2: [-10.0] ",-10.0f);
 
2827
                        m_fMaxAngle = AskFloat("    Enter the maximal value of this d2-ADF in deg/ps^2: [10.0] ",10.0f);
 
2828
                        break;
 
2829
        }
 
2830
 
 
2831
/*      if (m_fMaxAngle <= 90.0f)
 
2832
                m_bFoldAngle = AskYesNo("    Should angles > 90 deg be \"mirrored\" (180 deg = 0 deg) (y/n)? [yes] ",true);
 
2833
                        else*/ m_bFoldAngle = false;
 
2834
        m_bCosine = (AskRangeInteger("    Plot ADF against angle (0) or against cosine (1)? [0] ",0,1,0)!=0);
 
2835
        if (m_bCosine)
 
2836
        {
 
2837
                m_fMinAngle = (float)cos(m_fMinAngle/180.0*Pi);
 
2838
                m_fMaxAngle = (float)cos(m_fMaxAngle/180.0*Pi);
 
2839
                if (m_fMinAngle > m_fMaxAngle)
 
2840
                {
 
2841
                        tf = m_fMinAngle;
 
2842
                        m_fMinAngle = m_fMaxAngle;
 
2843
                        m_fMaxAngle = tf;
 
2844
                }
 
2845
                mprintf("    The data range is %.2f to %.2f.\n",m_fMinAngle,m_fMaxAngle);
 
2846
        }
 
2847
        if (!m_bCosine)
 
2848
                m_bMirror = AskYesNo("    Force this ADF to be mirror-symmetric to the 90 deg line (y/n)? [no] ",false);
 
2849
                        else m_bMirror = false;
 
2850
        m_iResolution = AskUnsignedInteger("    Please enter the resolution (bin count) for this ADF: [100] ",100);
 
2851
 
 
2852
        if (g_bAdvanced2)
 
2853
                m_iHistogramRes = AskUnsignedInteger("    Please enter histogram resolution (0=no histogram): [5000] ",5000);
 
2854
                        else m_iHistogramRes = 0;
 
2855
 
 
2856
        if (m_iShowMol != -1)
 
2857
                m_bStat = AskYesNo("    Apply cone correction (y/n)? [%c] ",!m_bCosine,(!m_bCosine)?'y':'n');
 
2858
                        else m_bStat = 0;
 
2859
/*      mprintf("\n    Save temporal development of this ADF (0=nein, 1=ja)? [0] ");
 
2860
        myget(buf);
 
2861
        m_bSaveAngle = (atoi(buf)!=0);*/
 
2862
        BuildName();
 
2863
        mprintf(WHITE,"\n<<< End of Angular Distribution Function <<<\n\n");
 
2864
        BTOUT;
 
2865
}
 
2866
 
 
2867
 
 
2868
void CDDF::Parse()
 
2869
{
 
2870
        BTIN;
 
2871
        char buf[256];
 
2872
        CAtomGroup *ag;
 
2873
        int z0, z, z2, i;
 
2874
        float tf;
 
2875
 
 
2876
        try { m_pDDF = new CDF(); } catch(...) { m_pDDF = NULL; }
 
2877
        if (m_pDDF == NULL) NewException((double)sizeof(CDF),__FILE__,__LINE__,__PRETTY_FUNCTION__);
 
2878
        
 
2879
        mprintf(WHITE,"\n>>> Dihedral Distribution Function >>>\n\n");
 
2880
        m_bClassical = AskYesNo("    Use \"simple\" (y) (4 atoms) or \"generalized\" (n) (3 vectors) Dihedrals? [yes] ",true);
 
2881
 
 
2882
        m_iCombinations = 1;
 
2883
        if (m_bClassical)
 
2884
        {
 
2885
                m_bOrtho[0] = false;
 
2886
                m_bOrtho[1] = false;
 
2887
                m_bOrtho[2] = false;
 
2888
                z0 = m_oaVectors.GetSize();
 
2889
                for (z=0;z<3;z++)
 
2890
                {
 
2891
                        try { ag = new CAtomGroup(); } catch(...) { ag = NULL; }
 
2892
                        if (ag == NULL) NewException((double)sizeof(CAtomGroup),__FILE__,__LINE__,__PRETTY_FUNCTION__);
 
2893
 
 
2894
                        m_oaVectors.Add(ag);
 
2895
 
 
2896
                        try { ag = new CAtomGroup(); } catch(...) { ag = NULL; }
 
2897
                        if (ag == NULL) NewException((double)sizeof(CAtomGroup),__FILE__,__LINE__,__PRETTY_FUNCTION__);
 
2898
 
 
2899
                        m_oaVectors.Add(ag);
 
2900
                        m_oaVectors.Add(NULL);
 
2901
                }
 
2902
                for (z=0;z<4;z++)
 
2903
                {
 
2904
_bx:            if (m_iShowMol != -1)
 
2905
                                i = AskRangeInteger("    Take the %d. atom from RM %s (0) or from OM %s (1)? [0] ",0,1,0,z+1,((CMolecule*)g_oaMolecules[g_iFixMol])->m_sName,((CMolecule*)g_oaMolecules[m_iShowMol])->m_sName);
 
2906
                                        else i = 0;
 
2907
                        switch(z)
 
2908
                        {
 
2909
                                case 0:
 
2910
                                        m_iRefOrSec[0][1] = i;
 
2911
                                        break;
 
2912
                                case 1:
 
2913
                                        m_iRefOrSec[0][0] = i;
 
2914
                                        m_iRefOrSec[2][0] = i;
 
2915
                                        break;
 
2916
                                case 2:
 
2917
                                        m_iRefOrSec[2][1] = i;
 
2918
                                        m_iRefOrSec[1][0] = i;
 
2919
                                        break;
 
2920
                                case 3:
 
2921
                                        m_iRefOrSec[1][1] = i;
 
2922
                                        break;
 
2923
                        }
 
2924
                        mprintf("      Enter the %d. atom(s) (e.g. C7): ",z+1);
 
2925
                        inpprintf("! Enter the %d. atom(s) (e.g. C7):\n",z+1);
 
2926
                        myget(buf);
 
2927
                        switch(z)
 
2928
                        {
 
2929
                                case 0:
 
2930
                                        if (!((CAtomGroup*)m_oaVectors[z0+0*3+1])->ParseAtoms((!m_iRefOrSec[0][1])?(CMolecule*)g_oaMolecules[g_iFixMol]:(CMolecule*)g_oaMolecules[m_iShowMol],buf))
 
2931
                                        {
 
2932
                                                eprintf("Wrong input.\n");
 
2933
                                                inpprintf("! Wrong input.\n");
 
2934
                                                goto _bx;
 
2935
                                        }
 
2936
                                        m_iCombinations *= ((CAtomGroup*)m_oaVectors[z0+0*3+1])->m_iAtomGes;
 
2937
                                        break;
 
2938
                                case 1:
 
2939
                                        if (!((CAtomGroup*)m_oaVectors[z0+0*3+0])->ParseAtoms((!m_iRefOrSec[0][0])?(CMolecule*)g_oaMolecules[g_iFixMol]:(CMolecule*)g_oaMolecules[m_iShowMol],buf))
 
2940
                                        {
 
2941
                                                eprintf("Wrong input.\n");
 
2942
                                                inpprintf("! Wrong input.\n");
 
2943
                                                goto _bx;
 
2944
                                        }
 
2945
                                        if (!((CAtomGroup*)m_oaVectors[z0+2*3+0])->ParseAtoms((!m_iRefOrSec[2][0])?(CMolecule*)g_oaMolecules[g_iFixMol]:(CMolecule*)g_oaMolecules[m_iShowMol],buf))
 
2946
                                        {
 
2947
                                                eprintf("Wrong input.\n");
 
2948
                                                inpprintf("! Wrong input.\n");
 
2949
                                                goto _bx;
 
2950
                                        }
 
2951
                                        m_iCombinations *= ((CAtomGroup*)m_oaVectors[z0+0*3+0])->m_iAtomGes;
 
2952
                                        m_iCombinations *= ((CAtomGroup*)m_oaVectors[z0+0*3+0])->m_iAtomGes;
 
2953
                                        break;
 
2954
                                case 2:
 
2955
                                        if (!((CAtomGroup*)m_oaVectors[z0+2*3+1])->ParseAtoms((!m_iRefOrSec[2][1])?(CMolecule*)g_oaMolecules[g_iFixMol]:(CMolecule*)g_oaMolecules[m_iShowMol],buf))
 
2956
                                        {
 
2957
                                                eprintf("Wrong input.\n");
 
2958
                                                inpprintf("! Wrong input.\n");
 
2959
                                                goto _bx;
 
2960
                                        }
 
2961
                                        if (!((CAtomGroup*)m_oaVectors[z0+1*3+0])->ParseAtoms((!m_iRefOrSec[1][0])?(CMolecule*)g_oaMolecules[g_iFixMol]:(CMolecule*)g_oaMolecules[m_iShowMol],buf))
 
2962
                                        {
 
2963
                                                eprintf("Wrong input.\n");
 
2964
                                                inpprintf("! Wrong input.\n");
 
2965
                                                goto _bx;
 
2966
                                        }
 
2967
                                        m_iCombinations *= ((CAtomGroup*)m_oaVectors[z0+2*3+1])->m_iAtomGes;
 
2968
                                        m_iCombinations *= ((CAtomGroup*)m_oaVectors[z0+2*3+1])->m_iAtomGes;
 
2969
                                        break;
 
2970
                                case 3:
 
2971
                                        if (!((CAtomGroup*)m_oaVectors[z0+1*3+1])->ParseAtoms((!m_iRefOrSec[1][1])?(CMolecule*)g_oaMolecules[g_iFixMol]:(CMolecule*)g_oaMolecules[m_iShowMol],buf))
 
2972
                                        {
 
2973
                                                eprintf("Wrong input.\n");
 
2974
                                                inpprintf("! Wrong input.\n");
 
2975
                                                goto _bx;
 
2976
                                        }
 
2977
                                        m_iCombinations *= ((CAtomGroup*)m_oaVectors[z0+1*3+1])->m_iAtomGes;
 
2978
                                        break;
 
2979
                        }
 
2980
                }
 
2981
        } else // NONCLASSIC
 
2982
        {
 
2983
                mprintf("\nYou now have to define 3 vectors:\n");
 
2984
                mprintf("The 1st and 2nd vector are projected onto the normal plane of the 3rd vector.\n");
 
2985
                mprintf("The angle between the two projected vectors in the plane is evaluated.\n");
 
2986
                for (z=0;z<3;z++)
 
2987
                {
 
2988
                        mprintf(WHITE,"\n  * Vector %d\n",z+1);
 
2989
                        m_bOrtho[z] = (AskRangeInteger("    Shall the %d. vector connect 2 points (0) or be orthogonal to a plane (1)? [0] ",0,1,0,z+1) != 0);
 
2990
                        if (m_bOrtho[z])
 
2991
                        {
 
2992
                                for (z2=0;z2<3;z2++)
 
2993
                                {
 
2994
                                        try { ag = new CAtomGroup(); } catch(...) { ag = NULL; }
 
2995
                                        if (ag == NULL) NewException((double)sizeof(CAtomGroup),__FILE__,__LINE__,__PRETTY_FUNCTION__);
 
2996
 
 
2997
_by:                            if (m_iShowMol != -1)
 
2998
                                                m_iRefOrSec[z][z2] = AskRangeInteger("    Take the %d. atom(s) of the plane from RM %s (0) or from OM %s (1)? [0] ",0,1,0,z2+1,((CMolecule*)g_oaMolecules[g_iFixMol])->m_sName,((CMolecule*)g_oaMolecules[m_iShowMol])->m_sName);
 
2999
                                                        else m_iRefOrSec[z][z2] = 0;
 
3000
                                        mprintf("      Please enter the %d. atom(s) (e.g. C7): ",z2+1);
 
3001
                                        inpprintf("! Please enter the %d. atom(s) (e.g. C7):\n",z2+1);
 
3002
                                        myget(buf);
 
3003
                                        if (!ag->ParseAtoms((!m_iRefOrSec[z][z2])?(CMolecule*)g_oaMolecules[g_iFixMol]:(CMolecule*)g_oaMolecules[m_iShowMol],buf))
 
3004
                                        {
 
3005
                                                eprintf("Wrong input.\n");
 
3006
                                                inpprintf("! Wrong input.\n");
 
3007
                                                goto _by;
 
3008
                                        }
 
3009
                                        m_iCombinations *= ag->m_iAtomGes;
 
3010
                                        m_oaVectors.Add(ag);
 
3011
                                }
 
3012
                        } else // Ortho
 
3013
                        {
 
3014
                                for (z2=0;z2<2;z2++)
 
3015
                                {
 
3016
                                        try { ag = new CAtomGroup(); } catch(...) { ag = NULL; }
 
3017
                                        if (ag == NULL) NewException((double)sizeof(CAtomGroup),__FILE__,__LINE__,__PRETTY_FUNCTION__);
 
3018
 
 
3019
_bz:                            if (m_iShowMol != -1)
 
3020
                                                m_iRefOrSec[z][z2] = AskRangeInteger("    Take the %d. atom(s) of the vector from RM %s (0) or from OM %s (1)? [0] ",0,1,0,z2+1,((CMolecule*)g_oaMolecules[g_iFixMol])->m_sName,((CMolecule*)g_oaMolecules[m_iShowMol])->m_sName);
 
3021
                                                        else m_iRefOrSec[z][z2] = 0;
 
3022
                                        mprintf("      Please enter the %d. atom(s) (e.g. C7): ",z2+1);
 
3023
                                        inpprintf("! Please enter the %d. atom(s) (e.g. C7):\n",z2+1);
 
3024
                                        myget(buf);
 
3025
                                        if (!ag->ParseAtoms((!m_iRefOrSec[z][z2])?(CMolecule*)g_oaMolecules[g_iFixMol]:(CMolecule*)g_oaMolecules[m_iShowMol],buf))
 
3026
                                        {
 
3027
                                                eprintf("Wrong input.\n");
 
3028
                                                inpprintf("! Wrong input.\n");
 
3029
                                                goto _bz;
 
3030
                                        }
 
3031
                                        m_iCombinations *= ag->m_iAtomGes;
 
3032
                                        m_oaVectors.Add(ag);
 
3033
                                }
 
3034
                                m_oaVectors.Add(NULL);
 
3035
                        } // ENDIF ORTHO
 
3036
                } // END FOR
 
3037
        } // END IF NONCLASSIC
 
3038
 
 
3039
/*      mprintf("\n");
 
3040
        mprintf("    The \"classical\" dihedral angle is defined for a range of 0 ... 180 deg.\n\n");
 
3041
        m_bAbs = !AskYesNo("    Do you want to extend the range to -180 ... +180 deg (y/n)? [no] ",false);*/
 
3042
 
 
3043
        mprintf("\n");
 
3044
        mprintf("    Per default, the dihedral angle is defined in a range of -180 ... 180 deg.\n\n");
 
3045
        m_bPositive = AskYesNo("    Use range of 0 ... 360 deg instead (e.g. -90 deg becomes 270 deg, ...) (y/n)? [no] ",false);
 
3046
        m_bAbs = false;
 
3047
        mprintf("\n");
 
3048
 
 
3049
        ParseDeriv();
 
3050
 
 
3051
        switch(m_iDeriv)
 
3052
        {
 
3053
                case 0:
 
3054
                        if (m_bPositive)
 
3055
                        {
 
3056
                                m_fMinAngle = AskFloat("\n    Enter minimal dihedral angle to observe:   [0 deg] ",0);
 
3057
                                m_fMaxAngle = AskFloat("    Enter maximal dihedral angle to observe: [360 deg] ",360.0f);
 
3058
                        } else
 
3059
                        {
 
3060
                                m_fMinAngle = AskFloat("\n    Enter minimal dihedral angle to observe: [-180 deg] ",-180.0f);
 
3061
                                m_fMaxAngle = AskFloat("    Enter maximal dihedral angle to observe:  [180 deg] ",180.0f);
 
3062
                        }
 
3063
                        break;
 
3064
                case 1:
 
3065
                        if (m_bDerivAbs)
 
3066
                                m_fMinAngle = AskFloat("    Enter the minimal value of this d1-DDF in deg/ps: [0] ",0.0f);
 
3067
                                        else m_fMinAngle = AskFloat("    Enter the minimal value of this d1-DDF in deg/ps: [-10.0] ",-10.0f);
 
3068
                        m_fMaxAngle = AskFloat("    Enter the maximal value of this d1-DDF in deg/ps: [10.0] ",10.0f);
 
3069
                        break;
 
3070
                case 2:
 
3071
                        if (m_bDerivAbs)
 
3072
                                m_fMinAngle = AskFloat("    Enter the minimal value of this d2-DDF in deg/ps^2: [0] ",0.0f);
 
3073
                                        else m_fMinAngle = AskFloat("    Enter the minimal value of this d2-DDF in deg/ps^2: [-10.0] ",-10.0f);
 
3074
                        m_fMaxAngle = AskFloat("    Enter the maximal value of this d2-DDF in deg/ps^2: [10.0] ",10.0f);
 
3075
                        break;
 
3076
        }
 
3077
 
 
3078
        if (m_iDeriv == 0)
 
3079
        {
 
3080
                m_bCosine = (AskRangeInteger("    Plot DDF against angle (0) or against cosine (1)? [0] ",0,1,0) != 0);
 
3081
                if (m_bCosine)
 
3082
                {
 
3083
                        if ((m_fMinAngle <= 0) && (m_fMaxAngle >= 0))
 
3084
                        {
 
3085
                                if (fabsf(m_fMinAngle) > fabsf(m_fMaxAngle))
 
3086
                                        m_fMinAngle = cosf(fabsf(m_fMinAngle));
 
3087
                                                else m_fMinAngle = cosf(fabsf(m_fMaxAngle));
 
3088
                                m_fMaxAngle = 1.0f;
3043
3089
                        } else
3044
 
                        {
3045
 
                                m_fMinAngle = AskFloat("\n    Enter minimal dihedral angle to observe: [-180 deg] ",-180.0f);
3046
 
                                m_fMaxAngle = AskFloat("    Enter maximal dihedral angle to observe:  [180 deg] ",180.0f);
3047
 
                        }
3048
 
                        break;
3049
 
                case 1:
3050
 
                        if (m_bDerivAbs)
3051
 
                                m_fMinAngle = AskFloat("    Enter the minimal value of this d1-DDF in deg/ps: [0] ",0.0f);
3052
 
                                        else m_fMinAngle = AskFloat("    Enter the minimal value of this d1-DDF in deg/ps: [-10.0] ",-10.0f);
3053
 
                        m_fMaxAngle = AskFloat("    Enter the maximal value of this d1-DDF in deg/ps: [10.0] ",10.0f);
3054
 
                        break;
3055
 
                case 2:
3056
 
                        if (m_bDerivAbs)
3057
 
                                m_fMinAngle = AskFloat("    Enter the minimal value of this d2-DDF in deg/ps^2: [0] ",0.0f);
3058
 
                                        else m_fMinAngle = AskFloat("    Enter the minimal value of this d2-DDF in deg/ps^2: [-10.0] ",-10.0f);
3059
 
                        m_fMaxAngle = AskFloat("    Enter the maximal value of this d2-DDF in deg/ps^2: [10.0] ",10.0f);
3060
 
                        break;
3061
 
        }
3062
 
 
3063
 
        if (m_iDeriv == 0)
3064
 
        {
3065
 
                m_bCosine = (AskRangeInteger("    Plot DDF against angle (0) or against cosine (1)? [0] ",0,1,0) != 0);
3066
 
                if (m_bCosine)
3067
 
                {
3068
 
                        m_fMinAngle = (float)cos(m_fMinAngle/180.0*Pi);
3069
 
                        m_fMaxAngle = (float)cos(m_fMaxAngle/180.0*Pi);
3070
 
                        if (m_fMinAngle > m_fMaxAngle)
3071
 
                        {
3072
 
                                tf = m_fMinAngle;
3073
 
                                m_fMinAngle = m_fMaxAngle;
3074
 
                                m_fMaxAngle = tf;
3075
 
                        }
3076
 
                        m_bAbs = false;
3077
 
                        m_bSymm = false;
3078
 
                        mprintf("\n    The data range is %.2f to %.2f.\n\n",m_fMinAngle,m_fMaxAngle);
3079
 
                } else
3080
 
                {
3081
 
/*                      m_bAbs = AskYesNo("    Use absolute angle values (y) or signed values (n)? [yes] ",true);
3082
 
                        if (!m_bAbs)
3083
 
                        {
3084
 
                                m_fMinAngle = -m_fMaxAngle;
3085
 
                                mprintf("\n    The data range is %.2f to %.2f.\n\n",m_fMinAngle,m_fMaxAngle);
3086
 
                                m_bSymm = AskYesNo("    Force this DDF to be symmetrical to the 0 degree line (y/n)? [no] ",false);
3087
 
                        } else m_bSymm = false;*/
3088
 
//                      if (!m_bAbs)
3089
 
//                      {
3090
 
//                              m_fMinAngle = -m_fMaxAngle;
3091
 
                                mprintf("\n    The data range is %.2f to %.2f.\n\n",m_fMinAngle,m_fMaxAngle);
3092
 
                                if (!m_bPositive)
3093
 
                                        m_bSymm = AskYesNo("    Add also bin entries for inverse angles (force symmetry) (y/n)? [no] ",false);
3094
 
                                                else m_bSymm = false;
3095
 
//                      } else m_bSymm = false;
3096
 
                }
3097
 
        } else 
3098
 
        {
3099
 
                m_bCosine = false;
3100
 
                m_bAbs = false;
3101
 
                m_bSymm = false;
3102
 
        }
3103
 
        m_iResolution = AskUnsignedInteger("    Please enter binning resolution for this DDF: [100] ",100);
3104
 
 
3105
 
        if (g_bAdvanced2)
3106
 
                m_iHistogramRes = AskUnsignedInteger("    Please enter histogram resolution (0=no histogram): [5000] ",5000);
3107
 
                        else m_iHistogramRes = 0;
3108
 
 
3109
 
/*      mprintf("\n    Save temporal Development of Dihedrals (0=no, 1=yes)? [0] ");
3110
 
        myget(buf);
3111
 
        m_bSaveAngle = atoi(buf)!=0;*/
3112
 
        BuildName();
3113
 
        mprintf(WHITE,"\n<<< End of Dihedral Distribution Function <<<\n\n");
3114
 
        BTOUT;
3115
 
}
3116
 
 
3117
 
 
3118
 
void CPlDF::Parse()
3119
 
{
3120
 
        BTIN;
3121
 
        char buf[256];
3122
 
        CAtomGroup *ag;
3123
 
        int z;
3124
 
 
3125
 
        try { m_pPlDF = new CDF(); } catch(...) { m_pPlDF = NULL; }
3126
 
        if (m_pPlDF == NULL) NewException((double)sizeof(CDF),__FILE__,__LINE__,__PRETTY_FUNCTION__);
3127
 
        
3128
 
        mprintf(WHITE,"\n>>> Plane Distance Distribution Function >>>\n\n");
3129
 
 
3130
 
        m_bNormal = !AskYesNo("    Define plane via 3 atoms (y) or as normal plane of a vector (n) (y/n)? [yes] ",true);
3131
 
 
3132
 
        m_iCombinations = 1;
3133
 
        if (m_bNormal)
3134
 
        {
3135
 
                try { ag = new CAtomGroup(); } catch(...) { ag = NULL; }
3136
 
                if (ag == NULL) NewException((double)sizeof(CAtomGroup),__FILE__,__LINE__,__PRETTY_FUNCTION__);
3137
 
_b2:    
3138
 
                if (m_iShowMol != -1)
3139
 
                        m_iRefOrSec[0] = AskRangeInteger("    Take the base atom of the vector/plane from RM %s (0) or from OM %s (1)? [0] ",0,1,0,((CMolecule*)g_oaMolecules[g_iFixMol])->m_sName,((CMolecule*)g_oaMolecules[m_iShowMol])->m_sName);
3140
 
                                else m_iRefOrSec[0] = 0;
3141
 
                mprintf("      Please enter the base atom (e.g. C7): ");
3142
 
                inpprintf("! Please enter the base atom (e.g. C7):\n");
3143
 
                myget(buf);
3144
 
                if (!ag->ParseAtoms((!m_iRefOrSec[0])?(CMolecule*)g_oaMolecules[g_iFixMol]:(CMolecule*)g_oaMolecules[m_iShowMol],buf))
3145
 
                {
3146
 
                        eprintf("Wrong input.\n");
3147
 
                        inpprintf("! Wrong input.\n");
3148
 
                        goto _b2;
3149
 
                }
3150
 
                m_iCombinations *= ag->m_iAtomGes;
3151
 
                m_oaVectors.Add(ag);
3152
 
 
3153
 
                try { ag = new CAtomGroup(); } catch(...) { ag = NULL; }
3154
 
                if (ag == NULL) NewException((double)sizeof(CAtomGroup),__FILE__,__LINE__,__PRETTY_FUNCTION__);
3155
 
_b3:    
3156
 
                if (m_iShowMol != -1)
3157
 
                        m_iRefOrSec[1] = AskRangeInteger("    Take the atom at the tip of the vector from RM %s (0) or from OM %s (1)? [0] ",0,1,0,((CMolecule*)g_oaMolecules[g_iFixMol])->m_sName,((CMolecule*)g_oaMolecules[m_iShowMol])->m_sName);
3158
 
                                else m_iRefOrSec[1] = 0;
3159
 
                mprintf("      Please enter the tip atom (e.g. C7): ");
3160
 
                inpprintf("! Please enter the tip atom (e.g. C7):\n");
3161
 
                myget(buf);
3162
 
                if (!ag->ParseAtoms((!m_iRefOrSec[1])?(CMolecule*)g_oaMolecules[g_iFixMol]:(CMolecule*)g_oaMolecules[m_iShowMol],buf))
3163
 
                {
3164
 
                        eprintf("Wrong input.\n");
3165
 
                        inpprintf("! Wrong input.\n");
3166
 
                        goto _b3;
3167
 
                }
3168
 
                m_iCombinations *= ag->m_iAtomGes;
3169
 
                m_oaVectors.Add(ag);
3170
 
                m_oaVectors.Add(NULL); // Dummy placeholder
3171
 
        } else
3172
 
        {
3173
 
                for (z=0;z<3;z++)
3174
 
                {
3175
 
                        try { ag = new CAtomGroup(); } catch(...) { ag = NULL; }
3176
 
                        if (ag == NULL) NewException((double)sizeof(CAtomGroup),__FILE__,__LINE__,__PRETTY_FUNCTION__);
3177
 
_b1:    
3178
 
                        if (m_iShowMol != -1)
3179
 
                                m_iRefOrSec[z] = AskRangeInteger("    Take the %d. atom(s) of the plane from RM %s (0) or from OM %s (1)? [0] ",0,1,0,z+1,((CMolecule*)g_oaMolecules[g_iFixMol])->m_sName,((CMolecule*)g_oaMolecules[m_iShowMol])->m_sName);
3180
 
                                        else m_iRefOrSec[z] = 0;
3181
 
                        mprintf("      Please enter the %d. atom (e.g. C7): ",z+1);
3182
 
                        inpprintf("! Please enter the %d. atom (e.g. C7):\n",z+1);
3183
 
                        myget(buf);
3184
 
                        if (!ag->ParseAtoms((!m_iRefOrSec[z])?(CMolecule*)g_oaMolecules[g_iFixMol]:(CMolecule*)g_oaMolecules[m_iShowMol],buf))
3185
 
                        {
3186
 
                                eprintf("Wrong input.\n");
3187
 
                                inpprintf("! Wrong input.\n");
3188
 
                                goto _b1;
3189
 
                        }
3190
 
                        m_iCombinations *= ag->m_iAtomGes;
3191
 
                        m_oaVectors.Add(ag);
3192
 
                }
3193
 
        }
3194
 
        mprintf("    Plane defined.\n\n");
3195
 
 
3196
 
        try { ag = new CAtomGroup(); } catch(...) { ag = NULL; }
3197
 
        if (ag == NULL) NewException((double)sizeof(CAtomGroup),__FILE__,__LINE__,__PRETTY_FUNCTION__);
3198
 
_b4:    
3199
 
        if (m_iShowMol != -1)
3200
 
                m_iRefOrSec[3] = AskRangeInteger("    Take the atom(s) to observe from RM %s (0) or from OM %s (1)? [0] ",0,1,0,((CMolecule*)g_oaMolecules[g_iFixMol])->m_sName,((CMolecule*)g_oaMolecules[m_iShowMol])->m_sName);
3201
 
                        else m_iRefOrSec[3] = 0;
3202
 
        mprintf("      Please enter the atom(s) to observe (e.g. C7): ");
3203
 
        inpprintf("! Please enter the atom(s) to observe (e.g. C7):\n");
3204
 
        myget(buf);
3205
 
        if (!ag->ParseAtoms((!m_iRefOrSec[3])?(CMolecule*)g_oaMolecules[g_iFixMol]:(CMolecule*)g_oaMolecules[m_iShowMol],buf))
3206
 
        {
3207
 
                eprintf("Wrong input.\n");
3208
 
                inpprintf("! Wrong input.\n");
3209
 
                goto _b4;
3210
 
        }
3211
 
        m_iCombinations *= ag->m_iAtomGes;
3212
 
        m_oaVectors.Add(ag);
3213
 
 
3214
 
        m_fMinDist = AskFloat("    Enter the minimal distance to observe (in pm): [-%d.0] ",(float)-HalfBox(),HalfBox());
3215
 
        m_fMaxDist = AskFloat("    Enter the maximal distance to observe (in pm): [%d.0] ",(float)HalfBox(),HalfBox());
3216
 
 
3217
 
        m_iResolution = AskUnsignedInteger("    Please enter binning resolution for this PlDF: [100] ",100);
3218
 
 
3219
 
        if (g_bAdvanced2)
3220
 
                m_iHistogramRes = AskUnsignedInteger("    Please enter histogram resolution (0=no histogram): [5000] ",5000);
3221
 
                        else m_iHistogramRes = 0;
3222
 
 
3223
 
        BuildName();
3224
 
        mprintf(WHITE,"\n<<< End of Plane Distance Distribution Function <<<\n\n");
3225
 
        BTOUT;
3226
 
}
3227
 
 
3228
 
 
3229
 
void CLiDF::Parse()
3230
 
{
3231
 
        BTIN;
3232
 
        char buf[256];
3233
 
        CAtomGroup *ag;
3234
 
        int z;
3235
 
 
3236
 
        try { m_pLiDF = new CDF(); } catch(...) { m_pLiDF = NULL; }
3237
 
        if (m_pLiDF == NULL) NewException((double)sizeof(CDF),__FILE__,__LINE__,__PRETTY_FUNCTION__);
3238
 
        
3239
 
        mprintf(WHITE,"\n>>> Line Distance Distribution Function >>>\n\n");
3240
 
 
3241
 
        m_bNormal = !AskYesNo("    Define line via 2 atoms (y) or as normal vector of a plane (n) (y/n)? [yes] ",true);
3242
 
 
3243
 
        m_iCombinations = 1;
3244
 
        if (m_bNormal)
3245
 
        {
3246
 
                mprintf("\n    The line will pass through the 1st point of the plane.\n\n");
3247
 
                for (z=0;z<3;z++)
3248
 
                {
3249
 
                        try { ag = new CAtomGroup(); } catch(...) { ag = NULL; }
3250
 
                        if (ag == NULL) NewException((double)sizeof(CAtomGroup),__FILE__,__LINE__,__PRETTY_FUNCTION__);
3251
 
        _b3:    
3252
 
                        if (m_iShowMol != -1)
3253
 
                                m_iRefOrSec[z] = AskRangeInteger("    Take the %d. atom(s) of the plane from RM %s (0) or from OM %s (1)? [0] ",0,1,0,z+1,((CMolecule*)g_oaMolecules[g_iFixMol])->m_sName,((CMolecule*)g_oaMolecules[m_iShowMol])->m_sName);
3254
 
                                        else m_iRefOrSec[z] = 0;
3255
 
                        mprintf("      Please enter the %d. atom (e.g. C7): ",z+1);
3256
 
                        inpprintf("! Please enter the %d. atom (e.g. C7):\n",z+1);
3257
 
                        myget(buf);
3258
 
                        if (!ag->ParseAtoms((!m_iRefOrSec[z])?(CMolecule*)g_oaMolecules[g_iFixMol]:(CMolecule*)g_oaMolecules[m_iShowMol],buf))
3259
 
                        {
3260
 
                                eprintf("Wrong input.\n");
3261
 
                                inpprintf("! Wrong input.\n");
3262
 
                                goto _b3;
3263
 
                        }
3264
 
                        m_iCombinations *= ag->m_iAtomGes;
3265
 
                        m_oaVectors.Add(ag);
3266
 
                }
3267
 
        } else
3268
 
        {
3269
 
                for (z=0;z<2;z++)
3270
 
                {
3271
 
                        try { ag = new CAtomGroup(); } catch(...) { ag = NULL; }
3272
 
                        if (ag == NULL) NewException((double)sizeof(CAtomGroup),__FILE__,__LINE__,__PRETTY_FUNCTION__);
3273
 
        _b1:    
3274
 
                        if (m_iShowMol != -1)
3275
 
                                m_iRefOrSec[z] = AskRangeInteger("    Take the %d. atom(s) of the line from RM %s (0) or from OM %s (1)? [0] ",0,1,0,z+1,((CMolecule*)g_oaMolecules[g_iFixMol])->m_sName,((CMolecule*)g_oaMolecules[m_iShowMol])->m_sName);
3276
 
                                        else m_iRefOrSec[z] = 0;
3277
 
                        mprintf("      Please enter the %d. atom (e.g. C7): ",z+1);
3278
 
                        inpprintf("! Please enter the %d. atom (e.g. C7):\n",z+1);
3279
 
                        myget(buf);
3280
 
                        if (!ag->ParseAtoms((!m_iRefOrSec[z])?(CMolecule*)g_oaMolecules[g_iFixMol]:(CMolecule*)g_oaMolecules[m_iShowMol],buf))
3281
 
                        {
3282
 
                                eprintf("Wrong input.\n");
3283
 
                                inpprintf("! Wrong input.\n");
3284
 
                                goto _b1;
3285
 
                        }
3286
 
                        m_iCombinations *= ag->m_iAtomGes;
3287
 
                        m_oaVectors.Add(ag);
3288
 
                }
3289
 
                m_oaVectors.Add(NULL);
3290
 
        }
3291
 
 
3292
 
        mprintf("    Line defined.\n\n");
3293
 
 
3294
 
        try { ag = new CAtomGroup(); } catch(...) { ag = NULL; }
3295
 
        if (ag == NULL) NewException((double)sizeof(CAtomGroup),__FILE__,__LINE__,__PRETTY_FUNCTION__);
3296
 
_b2:    
3297
 
        if (m_iShowMol != -1)
3298
 
                m_iRefOrSec[3] = AskRangeInteger("    Take the atom(s) to observe from RM %s (0) or from OM %s (1)? [0] ",0,1,0,((CMolecule*)g_oaMolecules[g_iFixMol])->m_sName,((CMolecule*)g_oaMolecules[m_iShowMol])->m_sName);
3299
 
                        else m_iRefOrSec[3] = 0;
3300
 
        mprintf("      Please enter the atom(s) to observe (e.g. C7): ");
3301
 
        inpprintf("! Please enter the atom(s) to observe (e.g. C7):\n");
3302
 
        myget(buf);
3303
 
        if (!ag->ParseAtoms((!m_iRefOrSec[3])?(CMolecule*)g_oaMolecules[g_iFixMol]:(CMolecule*)g_oaMolecules[m_iShowMol],buf))
3304
 
        {
3305
 
                eprintf("Wrong input.\n");
3306
 
                inpprintf("! Wrong input.\n");
3307
 
                goto _b2;
3308
 
        }
3309
 
        m_iCombinations *= ag->m_iAtomGes;
3310
 
        m_oaVectors.Add(ag);
3311
 
 
3312
 
        m_fMinDist = AskFloat("    Enter the minimal distance to observe (in pm): [0] ",0.0f);
3313
 
        m_fMaxDist = AskFloat("    Enter the maximal distance to observe (in pm): [%d.0] ",(float)HalfBox(),HalfBox());
3314
 
 
3315
 
        m_iResolution = AskUnsignedInteger("    Please enter binning resolution for this LiDF: [100] ",100);
3316
 
 
3317
 
        if (g_bAdvanced2)
3318
 
                m_iHistogramRes = AskUnsignedInteger("    Please enter histogram resolution (0=no histogram): [5000] ",5000);
3319
 
                        else m_iHistogramRes = 0;
3320
 
 
3321
 
        if (m_iShowMol != -1)
3322
 
                m_bRadialCorrect = AskYesNo("    Correct radial distribution for this LiDF (y/n)? [yes] ",true);
3323
 
                        else m_bRadialCorrect = AskYesNo("    Correct radial distribution for this LiDF (y/n)? [no] ",false);
3324
 
 
3325
 
        BuildName();
3326
 
        mprintf(WHITE,"\n<<< End of Line Distance Distribution Function <<<\n\n");
3327
 
        BTOUT;
3328
 
}
3329
 
 
3330
 
 
3331
 
void CDipDF::Parse()
3332
 
{
3333
 
        BTIN;
3334
 
        float tf;
3335
 
        double td, td2, td3;
3336
 
        CMolecule *m;
3337
 
        CSingleMolecule *sm;
3338
 
        int z;
3339
 
 
3340
 
        g_bDipole = true;
3341
 
 
3342
 
        try { m_pDipoleDF = new CDF(); } catch(...) { m_pDipoleDF = NULL; }
3343
 
        if (m_pDipoleDF == NULL) NewException((double)sizeof(CDF),__FILE__,__LINE__,__PRETTY_FUNCTION__);
3344
 
        
3345
 
        mprintf(WHITE,"\n>>> Dipole Distribution Function >>>\n\n");
3346
 
        if (m_iShowMol != -1)
3347
 
                m_iRefOrSec = AskRangeInteger("    Observe dipole moment from RM %s (0) or from OM %s (1)? [0] ",0,1,0,((CMolecule*)g_oaMolecules[g_iFixMol])->m_sName,((CMolecule*)g_oaMolecules[m_iShowMol])->m_sName);
3348
 
                        else m_iRefOrSec = 0;
3349
 
 
3350
 
        ParseDeriv();
3351
 
 
3352
 
        if (m_iRefOrSec != 0)
3353
 
                m = (CMolecule*)g_oaMolecules[m_iShowMol];
3354
 
                        else m = (CMolecule*)g_oaMolecules[g_iFixMol];
3355
 
 
3356
 
        td = 0;
3357
 
        td2 = 1.0e10;
3358
 
        td3 = 0;
3359
 
        for (z=0;z<m->m_laSingleMolIndex.GetSize();z++)
3360
 
        {
3361
 
                sm = (CSingleMolecule*)g_oaSingleMolecules[m->m_laSingleMolIndex[z]];
3362
 
                tf = sm->m_vDipole.GetLength();
3363
 
                if (tf > td)
3364
 
                        td = tf;
3365
 
                if (tf < td2)
3366
 
                        td2 = tf;
3367
 
                td3 += tf;
3368
 
        }
3369
 
        td3 /= (double)m->m_laSingleMolIndex.GetSize();
3370
 
 
3371
 
        mprintf("\n    Dipole moment of %s (1st step): Min. %.3f, Max. %.3f, Avg. %.3f Debye.\n\n",m->m_sName,td2,td,td3);
3372
 
 
3373
 
        switch(m_iDeriv)
3374
 
        {
3375
 
                case 0:
3376
 
                        m_fDipoleMin = AskFloat("    Enter the lower bound for dipole values (in Debye): [0] ",0.0f);
3377
 
                        m_fDipoleMax = AskFloat("    Enter the upper bound for dipole values (in Debye): [%d] ",float(int(td*2.0)),int(td*2.0));
3378
 
                        break;
3379
 
                case 1:
3380
 
                        if (m_bDerivAbs)
3381
 
                                m_fDipoleMin = AskFloat("    Enter the minimal value of this d1-DDF in Debye/ps: [0] ",0.0f);
3382
 
                                        else m_fDipoleMin = AskFloat("    Enter the minimal value of this d1-DDF in Debye/ps: [-10.0] ",-10.0f);
3383
 
                        m_fDipoleMax = AskFloat("    Enter the maximal value of this d1-DDF in Debye/ps: [10.0] ",10.0f);
3384
 
                        break;
3385
 
                case 2:
3386
 
                        if (m_bDerivAbs)
3387
 
                                m_fDipoleMin = AskFloat("    Enter the minimal value of this d2-DDF in Debye/ps^2: [0] ",0.0f);
3388
 
                                        else m_fDipoleMin = AskFloat("    Enter the minimal value of this d2-DDF in Debye/ps^2: [-10.0] ",-10.0f);
3389
 
                        m_fDipoleMax = AskFloat("    Enter the maximal value of this d2-DDF in Debye/ps^2: [10.0] ",10.0f);
3390
 
                        break;
3391
 
        }
3392
 
 
3393
 
        m_iResolution = AskUnsignedInteger("    Enter binning resolution for the Dipole DF: [%d] ",int((m_fDipoleMax-m_fDipoleMin)*10.0),int((m_fDipoleMax-m_fDipoleMin)*10.0));
3394
 
 
3395
 
        if (g_bAdvanced2)
3396
 
                m_iHistogramRes = AskUnsignedInteger("    Please enter histogram resolution (0=no histogram): [5000] ",5000);
3397
 
                        else m_iHistogramRes = 0;
3398
 
 
3399
 
        BuildName();
3400
 
        mprintf(WHITE,"\n<<< End of Dipole Distribution Function <<<\n\n");
3401
 
        BTOUT;
3402
 
}
3403
 
 
3404
 
 
3405
 
void CSDF::Parse(bool voro)
3406
 
{
3407
 
        BTIN;
3408
 
        int ti;
3409
 
        char buf[256];
3410
 
 
3411
 
        m_iShowAtomGes = 0;
3412
 
 
3413
 
        try { m_pSDF = new C3DF(); } catch(...) { m_pSDF = NULL; }
3414
 
        if (m_pSDF == NULL) NewException((double)sizeof(C3DF),__FILE__,__LINE__,__PRETTY_FUNCTION__);
3415
 
        
3416
 
        mprintf(WHITE,"\n>>> Spatial Distribution Function >>>\n\n");
3417
 
_sdfatoms:
3418
 
        if (!voro)
3419
 
        {
3420
 
                if (m_bIntra)
3421
 
                {
3422
 
                        mprintf("    Observing atoms in reference molecule %s.\n",((CMolecule*)g_oaMolecules[g_iFixMol])->m_sName);
3423
 
                        m_iRefOrSec = 0;
3424
 
                } else
3425
 
                {
3426
 
                        mprintf("    Observing atoms in observed molecule %s.\n",((CMolecule*)g_oaMolecules[m_iShowMol])->m_sName);
3427
 
                        m_iRefOrSec = 1;
3428
 
                }
3429
 
        /*      if (m_iShowMol != -1)
3430
 
                        m_iRefOrSec = AskRangeInteger("    Observe atoms in RM %s (0) or in OM %s (1)? [1] ",0,1,1,((CMolecule*)g_oaMolecules[g_iFixMol])->m_sName,((CMolecule*)g_oaMolecules[m_iShowMol])->m_sName);
3431
 
                                else m_iRefOrSec = 0;*/
3432
 
                mprintf("    Which atoms to observe (e.g. \"C1,C3-5,H\", \"*\"=all)? [#2] ");
3433
 
                inpprintf("! Which atoms to observe (e.g. \"C1,C3-5,H\", \"*\"=all)? [#2]\n");
3434
 
                myget(buf);
3435
 
                if (strlen(buf) == 0)
3436
 
                {
3437
 
                        if (!m_oAtoms.ParseAtoms((CMolecule*)g_oaMolecules[(m_iRefOrSec==0)?g_iFixMol:m_iShowMol],"#2"))
3438
 
                        {
3439
 
                                eprintf("Strange error ^^\n");
3440
 
                                inpprintf("! Strange error ^\n");
3441
 
                                goto _sdfatoms;
3442
 
                        }
3443
 
                } else 
3444
 
                {
3445
 
                        if (!m_oAtoms.ParseAtoms((CMolecule*)g_oaMolecules[(m_iRefOrSec==0)?g_iFixMol:m_iShowMol],buf))
3446
 
                        {
3447
 
                                eprintf("Wrong input.\n");
3448
 
                                inpprintf("! Wrong input.\n");
3449
 
                                goto _sdfatoms;
3450
 
                        }
3451
 
                }
3452
 
 
3453
 
                m_iShowAtomGes += m_oAtoms.m_iAtomGes;
3454
 
                m_fParticleDensity = m_oAtoms.m_iAtomGes * ((CMolecule*)g_oaMolecules[(m_iRefOrSec==0)?g_iFixMol:m_iShowMol])->m_laSingleMolIndex.GetSize() / g_fBoxX / g_fBoxY / g_fBoxZ * 1E9f;
3455
 
        }
3456
 
 
3457
 
        m_fRadius = AskFloat("    Please enter radius of this SDF in pm: [%d.0] ",(float)HalfBox(),HalfBox());
3458
 
_sdfresagain:
3459
 
        ti = g_pDatabase->GetInt("/PLOT3D/DEFAULTS/BIN_RES");
3460
 
        m_iResolution = AskUnsignedInteger("    Please enter binning resolution of this SDF per dimension: [%d] ",ti,ti);
3461
 
 
3462
 
        if (m_iResolution > 300)
3463
 
        {
3464
 
                eprintf("\nWarning: ");
3465
 
                mprintf("This large resolution will consume much RAM (%s)\n",FormatBytes(pow((double)m_iResolution,3)*sizeof(double)));
3466
 
                mprintf("         and result in very large SDF output files.\n\n");
3467
 
                if (!AskYesNo("    Use this resolution (y/n)? [no] ",false))
3468
 
                        goto _sdfresagain;
3469
 
        }
3470
 
 
3471
 
        if (g_bAdvanced2)
3472
 
        {
3473
 
                m_bVdWSpheres = false; //AskYesNo("    Process atoms as VdW spheres rather than points (y/n)? [no] ",false);
3474
 
                m_iHistogramRes = AskUnsignedInteger("    Please enter histogram resolution (0=no histogram): [5000] ",5000);
3475
 
                m_bClipPlane = AskYesNo("    Use a clipping plane for this SDF (y/n)? [no] ",false);
3476
 
                if (m_bClipPlane)
3477
 
                {
3478
 
        _cut:   mprintf("    Should the clipping plane stand perpendicular to the X, Y or Z axis (x/y/z)? [x] ");
3479
 
                        inpprintf("! Should the clipping plane stand perpendicular to the X, Y or Z axis (x/y/z)? [x]\n");
3480
 
                        myget(buf);
3481
 
                        switch(tolower(buf[0]))
3482
 
                        {
3483
 
                                case 0:
3484
 
                                case 'x':
3485
 
                                        m_iClipDirection = 0;
3486
 
                                        break;
3487
 
                                case 'y':
3488
 
                                        m_iClipDirection = 1;
3489
 
                                        break;
3490
 
                                case 'z':
3491
 
                                        m_iClipDirection = 2;
3492
 
                                        break;
3493
 
                                default:
3494
 
                                        eprintf("    Wrong input! Please enter 'x', 'y' or 'z'.\n");
3495
 
                                        inpprintf("! Wrong input! Please enter 'x', 'y' or 'z'.\n");
3496
 
                                        goto _cut;      
3497
 
                        }
3498
 
                        m_fClipValue = AskFloat("    Please enter distance of clipping plane from origin (in pm): [0] ",0.0f);
3499
 
                }
3500
 
                m_bInvert = AskYesNo("    Should this SDF be inverted (y/n)? [no] ",false);
3501
 
                m_bSDFMirrorXY = AskYesNo("    Force this SDF to be symmetrical to the XY plane (y/n)? [no] ",false);
3502
 
                m_bSDFMirrorBisect = AskYesNo("    Force this SDF to be symmetrical to the angle bisector (y/n)? [no] ",false);
3503
 
                m_bCutPlane = AskYesNo("    Add a particle density cut plane to this SDF (y/n)? [no] ",false);
3504
 
                if (m_bCutPlane)
3505
 
                {
3506
 
                        m_iCutPlaneResolution = AskUnsignedInteger("    Enter the binning resolution for the cut plane per dimension: [100] ",100);
3507
 
                        m_bCutPlaneShowAtoms = AskYesNo("    Show reference atoms in Pseudo SDF plot (y/n)? [yes] ",true);
3508
 
                }
3509
 
        } else
3510
 
        {
3511
 
                m_bVdWSpheres = false;
 
3090
                        {
 
3091
                                m_fMinAngle = cosf(m_fMinAngle/180.0f*Pi);
 
3092
                                m_fMaxAngle = cosf(m_fMaxAngle/180.0f*Pi);
 
3093
                        }
 
3094
                        if (m_fMinAngle > m_fMaxAngle)
 
3095
                        {
 
3096
                                tf = m_fMinAngle;
 
3097
                                m_fMinAngle = m_fMaxAngle;
 
3098
                                m_fMaxAngle = tf;
 
3099
                        }
 
3100
                        m_bAbs = false;
 
3101
                        m_bSymm = false;
 
3102
                        mprintf("\n    The data range is %.2f to %.2f.\n\n",m_fMinAngle,m_fMaxAngle);
 
3103
                } else
 
3104
                {
 
3105
/*                      m_bAbs = AskYesNo("    Use absolute angle values (y) or signed values (n)? [yes] ",true);
 
3106
                        if (!m_bAbs)
 
3107
                        {
 
3108
                                m_fMinAngle = -m_fMaxAngle;
 
3109
                                mprintf("\n    The data range is %.2f to %.2f.\n\n",m_fMinAngle,m_fMaxAngle);
 
3110
                                m_bSymm = AskYesNo("    Force this DDF to be symmetrical to the 0 degree line (y/n)? [no] ",false);
 
3111
                        } else m_bSymm = false;*/
 
3112
//                      if (!m_bAbs)
 
3113
//                      {
 
3114
//                              m_fMinAngle = -m_fMaxAngle;
 
3115
                                mprintf("\n    The data range is %.2f to %.2f.\n\n",m_fMinAngle,m_fMaxAngle);
 
3116
                                if (!m_bPositive)
 
3117
                                        m_bSymm = AskYesNo("    Add also bin entries for inverse angles (force symmetry) (y/n)? [no] ",false);
 
3118
                                                else m_bSymm = false;
 
3119
//                      } else m_bSymm = false;
 
3120
                }
 
3121
        } else 
 
3122
        {
 
3123
                m_bCosine = false;
 
3124
                m_bAbs = false;
 
3125
                m_bSymm = false;
 
3126
        }
 
3127
        m_iResolution = AskUnsignedInteger("    Please enter binning resolution for this DDF: [100] ",100);
 
3128
 
 
3129
        if (g_bAdvanced2)
 
3130
                m_iHistogramRes = AskUnsignedInteger("    Please enter histogram resolution (0=no histogram): [5000] ",5000);
 
3131
                        else m_iHistogramRes = 0;
 
3132
 
 
3133
/*      mprintf("\n    Save temporal Development of Dihedrals (0=no, 1=yes)? [0] ");
 
3134
        myget(buf);
 
3135
        m_bSaveAngle = atoi(buf)!=0;*/
 
3136
        BuildName();
 
3137
        mprintf(WHITE,"\n<<< End of Dihedral Distribution Function <<<\n\n");
 
3138
        BTOUT;
 
3139
}
 
3140
 
 
3141
 
 
3142
void CPlDF::Parse()
 
3143
{
 
3144
        BTIN;
 
3145
        char buf[256];
 
3146
        CAtomGroup *ag;
 
3147
        int z;
 
3148
 
 
3149
        try { m_pPlDF = new CDF(); } catch(...) { m_pPlDF = NULL; }
 
3150
        if (m_pPlDF == NULL) NewException((double)sizeof(CDF),__FILE__,__LINE__,__PRETTY_FUNCTION__);
 
3151
        
 
3152
        mprintf(WHITE,"\n>>> Plane Distance Distribution Function >>>\n\n");
 
3153
 
 
3154
        m_bNormal = !AskYesNo("    Define plane via 3 atoms (y) or as normal plane of a vector (n) (y/n)? [yes] ",true);
 
3155
 
 
3156
        m_iCombinations = 1;
 
3157
        if (m_bNormal)
 
3158
        {
 
3159
                try { ag = new CAtomGroup(); } catch(...) { ag = NULL; }
 
3160
                if (ag == NULL) NewException((double)sizeof(CAtomGroup),__FILE__,__LINE__,__PRETTY_FUNCTION__);
 
3161
_b2:    
 
3162
                if (m_iShowMol != -1)
 
3163
                        m_iRefOrSec[0] = AskRangeInteger("    Take the base atom of the vector/plane from RM %s (0) or from OM %s (1)? [0] ",0,1,0,((CMolecule*)g_oaMolecules[g_iFixMol])->m_sName,((CMolecule*)g_oaMolecules[m_iShowMol])->m_sName);
 
3164
                                else m_iRefOrSec[0] = 0;
 
3165
                mprintf("      Please enter the base atom (e.g. C7): ");
 
3166
                inpprintf("! Please enter the base atom (e.g. C7):\n");
 
3167
                myget(buf);
 
3168
                if (!ag->ParseAtoms((!m_iRefOrSec[0])?(CMolecule*)g_oaMolecules[g_iFixMol]:(CMolecule*)g_oaMolecules[m_iShowMol],buf))
 
3169
                {
 
3170
                        eprintf("Wrong input.\n");
 
3171
                        inpprintf("! Wrong input.\n");
 
3172
                        goto _b2;
 
3173
                }
 
3174
                m_iCombinations *= ag->m_iAtomGes;
 
3175
                m_oaVectors.Add(ag);
 
3176
 
 
3177
                try { ag = new CAtomGroup(); } catch(...) { ag = NULL; }
 
3178
                if (ag == NULL) NewException((double)sizeof(CAtomGroup),__FILE__,__LINE__,__PRETTY_FUNCTION__);
 
3179
_b3:    
 
3180
                if (m_iShowMol != -1)
 
3181
                        m_iRefOrSec[1] = AskRangeInteger("    Take the atom at the tip of the vector from RM %s (0) or from OM %s (1)? [0] ",0,1,0,((CMolecule*)g_oaMolecules[g_iFixMol])->m_sName,((CMolecule*)g_oaMolecules[m_iShowMol])->m_sName);
 
3182
                                else m_iRefOrSec[1] = 0;
 
3183
                mprintf("      Please enter the tip atom (e.g. C7): ");
 
3184
                inpprintf("! Please enter the tip atom (e.g. C7):\n");
 
3185
                myget(buf);
 
3186
                if (!ag->ParseAtoms((!m_iRefOrSec[1])?(CMolecule*)g_oaMolecules[g_iFixMol]:(CMolecule*)g_oaMolecules[m_iShowMol],buf))
 
3187
                {
 
3188
                        eprintf("Wrong input.\n");
 
3189
                        inpprintf("! Wrong input.\n");
 
3190
                        goto _b3;
 
3191
                }
 
3192
                m_iCombinations *= ag->m_iAtomGes;
 
3193
                m_oaVectors.Add(ag);
 
3194
                m_oaVectors.Add(NULL); // Dummy placeholder
 
3195
        } else
 
3196
        {
 
3197
                for (z=0;z<3;z++)
 
3198
                {
 
3199
                        try { ag = new CAtomGroup(); } catch(...) { ag = NULL; }
 
3200
                        if (ag == NULL) NewException((double)sizeof(CAtomGroup),__FILE__,__LINE__,__PRETTY_FUNCTION__);
 
3201
_b1:    
 
3202
                        if (m_iShowMol != -1)
 
3203
                                m_iRefOrSec[z] = AskRangeInteger("    Take the %d. atom(s) of the plane from RM %s (0) or from OM %s (1)? [0] ",0,1,0,z+1,((CMolecule*)g_oaMolecules[g_iFixMol])->m_sName,((CMolecule*)g_oaMolecules[m_iShowMol])->m_sName);
 
3204
                                        else m_iRefOrSec[z] = 0;
 
3205
                        mprintf("      Please enter the %d. atom (e.g. C7): ",z+1);
 
3206
                        inpprintf("! Please enter the %d. atom (e.g. C7):\n",z+1);
 
3207
                        myget(buf);
 
3208
                        if (!ag->ParseAtoms((!m_iRefOrSec[z])?(CMolecule*)g_oaMolecules[g_iFixMol]:(CMolecule*)g_oaMolecules[m_iShowMol],buf))
 
3209
                        {
 
3210
                                eprintf("Wrong input.\n");
 
3211
                                inpprintf("! Wrong input.\n");
 
3212
                                goto _b1;
 
3213
                        }
 
3214
                        m_iCombinations *= ag->m_iAtomGes;
 
3215
                        m_oaVectors.Add(ag);
 
3216
                }
 
3217
        }
 
3218
        mprintf("    Plane defined.\n\n");
 
3219
 
 
3220
        try { ag = new CAtomGroup(); } catch(...) { ag = NULL; }
 
3221
        if (ag == NULL) NewException((double)sizeof(CAtomGroup),__FILE__,__LINE__,__PRETTY_FUNCTION__);
 
3222
_b4:    
 
3223
        if (m_iShowMol != -1)
 
3224
                m_iRefOrSec[3] = AskRangeInteger("    Take the atom(s) to observe from RM %s (0) or from OM %s (1)? [0] ",0,1,0,((CMolecule*)g_oaMolecules[g_iFixMol])->m_sName,((CMolecule*)g_oaMolecules[m_iShowMol])->m_sName);
 
3225
                        else m_iRefOrSec[3] = 0;
 
3226
        mprintf("      Please enter the atom(s) to observe (e.g. C7): ");
 
3227
        inpprintf("! Please enter the atom(s) to observe (e.g. C7):\n");
 
3228
        myget(buf);
 
3229
        if (!ag->ParseAtoms((!m_iRefOrSec[3])?(CMolecule*)g_oaMolecules[g_iFixMol]:(CMolecule*)g_oaMolecules[m_iShowMol],buf))
 
3230
        {
 
3231
                eprintf("Wrong input.\n");
 
3232
                inpprintf("! Wrong input.\n");
 
3233
                goto _b4;
 
3234
        }
 
3235
        m_iCombinations *= ag->m_iAtomGes;
 
3236
        m_oaVectors.Add(ag);
 
3237
 
 
3238
        m_fMinDist = AskFloat("    Enter the minimal distance to observe (in pm): [-%d.0] ",(float)-HalfBox(),HalfBox());
 
3239
        m_fMaxDist = AskFloat("    Enter the maximal distance to observe (in pm): [%d.0] ",(float)HalfBox(),HalfBox());
 
3240
 
 
3241
        m_iResolution = AskUnsignedInteger("    Please enter binning resolution for this PlDF: [100] ",100);
 
3242
 
 
3243
        if (g_bAdvanced2)
 
3244
                m_iHistogramRes = AskUnsignedInteger("    Please enter histogram resolution (0=no histogram): [5000] ",5000);
 
3245
                        else m_iHistogramRes = 0;
 
3246
 
 
3247
        BuildName();
 
3248
        mprintf(WHITE,"\n<<< End of Plane Distance Distribution Function <<<\n\n");
 
3249
        BTOUT;
 
3250
}
 
3251
 
 
3252
 
 
3253
void CLiDF::Parse()
 
3254
{
 
3255
        BTIN;
 
3256
        char buf[256];
 
3257
        CAtomGroup *ag;
 
3258
        int z;
 
3259
 
 
3260
        try { m_pLiDF = new CDF(); } catch(...) { m_pLiDF = NULL; }
 
3261
        if (m_pLiDF == NULL) NewException((double)sizeof(CDF),__FILE__,__LINE__,__PRETTY_FUNCTION__);
 
3262
        
 
3263
        mprintf(WHITE,"\n>>> Line Distance Distribution Function >>>\n\n");
 
3264
 
 
3265
        m_bNormal = !AskYesNo("    Define line via 2 atoms (y) or as normal vector of a plane (n) (y/n)? [yes] ",true);
 
3266
 
 
3267
        m_iCombinations = 1;
 
3268
        if (m_bNormal)
 
3269
        {
 
3270
                mprintf("\n    The line will pass through the 1st point of the plane.\n\n");
 
3271
                for (z=0;z<3;z++)
 
3272
                {
 
3273
                        try { ag = new CAtomGroup(); } catch(...) { ag = NULL; }
 
3274
                        if (ag == NULL) NewException((double)sizeof(CAtomGroup),__FILE__,__LINE__,__PRETTY_FUNCTION__);
 
3275
        _b3:    
 
3276
                        if (m_iShowMol != -1)
 
3277
                                m_iRefOrSec[z] = AskRangeInteger("    Take the %d. atom(s) of the plane from RM %s (0) or from OM %s (1)? [0] ",0,1,0,z+1,((CMolecule*)g_oaMolecules[g_iFixMol])->m_sName,((CMolecule*)g_oaMolecules[m_iShowMol])->m_sName);
 
3278
                                        else m_iRefOrSec[z] = 0;
 
3279
                        mprintf("      Please enter the %d. atom (e.g. C7): ",z+1);
 
3280
                        inpprintf("! Please enter the %d. atom (e.g. C7):\n",z+1);
 
3281
                        myget(buf);
 
3282
                        if (!ag->ParseAtoms((!m_iRefOrSec[z])?(CMolecule*)g_oaMolecules[g_iFixMol]:(CMolecule*)g_oaMolecules[m_iShowMol],buf))
 
3283
                        {
 
3284
                                eprintf("Wrong input.\n");
 
3285
                                inpprintf("! Wrong input.\n");
 
3286
                                goto _b3;
 
3287
                        }
 
3288
                        m_iCombinations *= ag->m_iAtomGes;
 
3289
                        m_oaVectors.Add(ag);
 
3290
                }
 
3291
        } else
 
3292
        {
 
3293
                for (z=0;z<2;z++)
 
3294
                {
 
3295
                        try { ag = new CAtomGroup(); } catch(...) { ag = NULL; }
 
3296
                        if (ag == NULL) NewException((double)sizeof(CAtomGroup),__FILE__,__LINE__,__PRETTY_FUNCTION__);
 
3297
        _b1:    
 
3298
                        if (m_iShowMol != -1)
 
3299
                                m_iRefOrSec[z] = AskRangeInteger("    Take the %d. atom(s) of the line from RM %s (0) or from OM %s (1)? [0] ",0,1,0,z+1,((CMolecule*)g_oaMolecules[g_iFixMol])->m_sName,((CMolecule*)g_oaMolecules[m_iShowMol])->m_sName);
 
3300
                                        else m_iRefOrSec[z] = 0;
 
3301
                        mprintf("      Please enter the %d. atom (e.g. C7): ",z+1);
 
3302
                        inpprintf("! Please enter the %d. atom (e.g. C7):\n",z+1);
 
3303
                        myget(buf);
 
3304
                        if (!ag->ParseAtoms((!m_iRefOrSec[z])?(CMolecule*)g_oaMolecules[g_iFixMol]:(CMolecule*)g_oaMolecules[m_iShowMol],buf))
 
3305
                        {
 
3306
                                eprintf("Wrong input.\n");
 
3307
                                inpprintf("! Wrong input.\n");
 
3308
                                goto _b1;
 
3309
                        }
 
3310
                        m_iCombinations *= ag->m_iAtomGes;
 
3311
                        m_oaVectors.Add(ag);
 
3312
                }
 
3313
                m_oaVectors.Add(NULL);
 
3314
        }
 
3315
 
 
3316
        mprintf("    Line defined.\n\n");
 
3317
 
 
3318
        try { ag = new CAtomGroup(); } catch(...) { ag = NULL; }
 
3319
        if (ag == NULL) NewException((double)sizeof(CAtomGroup),__FILE__,__LINE__,__PRETTY_FUNCTION__);
 
3320
_b2:    
 
3321
        if (m_iShowMol != -1)
 
3322
                m_iRefOrSec[3] = AskRangeInteger("    Take the atom(s) to observe from RM %s (0) or from OM %s (1)? [0] ",0,1,0,((CMolecule*)g_oaMolecules[g_iFixMol])->m_sName,((CMolecule*)g_oaMolecules[m_iShowMol])->m_sName);
 
3323
                        else m_iRefOrSec[3] = 0;
 
3324
        mprintf("      Please enter the atom(s) to observe (e.g. C7): ");
 
3325
        inpprintf("! Please enter the atom(s) to observe (e.g. C7):\n");
 
3326
        myget(buf);
 
3327
        if (!ag->ParseAtoms((!m_iRefOrSec[3])?(CMolecule*)g_oaMolecules[g_iFixMol]:(CMolecule*)g_oaMolecules[m_iShowMol],buf))
 
3328
        {
 
3329
                eprintf("Wrong input.\n");
 
3330
                inpprintf("! Wrong input.\n");
 
3331
                goto _b2;
 
3332
        }
 
3333
        m_iCombinations *= ag->m_iAtomGes;
 
3334
        m_oaVectors.Add(ag);
 
3335
 
 
3336
        m_fMinDist = AskFloat("    Enter the minimal distance to observe (in pm): [0] ",0.0f);
 
3337
        m_fMaxDist = AskFloat("    Enter the maximal distance to observe (in pm): [%d.0] ",(float)HalfBox(),HalfBox());
 
3338
 
 
3339
        m_iResolution = AskUnsignedInteger("    Please enter binning resolution for this LiDF: [100] ",100);
 
3340
 
 
3341
        if (g_bAdvanced2)
 
3342
                m_iHistogramRes = AskUnsignedInteger("    Please enter histogram resolution (0=no histogram): [5000] ",5000);
 
3343
                        else m_iHistogramRes = 0;
 
3344
 
 
3345
        if (m_iShowMol != -1)
 
3346
                m_bRadialCorrect = AskYesNo("    Correct radial distribution for this LiDF (y/n)? [yes] ",true);
 
3347
                        else m_bRadialCorrect = AskYesNo("    Correct radial distribution for this LiDF (y/n)? [no] ",false);
 
3348
 
 
3349
        BuildName();
 
3350
        mprintf(WHITE,"\n<<< End of Line Distance Distribution Function <<<\n\n");
 
3351
        BTOUT;
 
3352
}
 
3353
 
 
3354
 
 
3355
void CDipDF::Parse()
 
3356
{
 
3357
        BTIN;
 
3358
        float tf;
 
3359
        double td, td2, td3;
 
3360
        CMolecule *m;
 
3361
        CSingleMolecule *sm;
 
3362
        int z;
 
3363
 
 
3364
        g_bDipole = true;
 
3365
 
 
3366
        try { m_pDipoleDF = new CDF(); } catch(...) { m_pDipoleDF = NULL; }
 
3367
        if (m_pDipoleDF == NULL) NewException((double)sizeof(CDF),__FILE__,__LINE__,__PRETTY_FUNCTION__);
 
3368
        
 
3369
        mprintf(WHITE,"\n>>> Dipole Distribution Function >>>\n\n");
 
3370
        if (m_iShowMol != -1)
 
3371
                m_iRefOrSec = AskRangeInteger("    Observe dipole moment from RM %s (0) or from OM %s (1)? [0] ",0,1,0,((CMolecule*)g_oaMolecules[g_iFixMol])->m_sName,((CMolecule*)g_oaMolecules[m_iShowMol])->m_sName);
 
3372
                        else m_iRefOrSec = 0;
 
3373
 
 
3374
        ParseDeriv();
 
3375
 
 
3376
        if (m_iRefOrSec != 0)
 
3377
                m = (CMolecule*)g_oaMolecules[m_iShowMol];
 
3378
                        else m = (CMolecule*)g_oaMolecules[g_iFixMol];
 
3379
 
 
3380
        td = 0;
 
3381
        td2 = 1.0e10;
 
3382
        td3 = 0;
 
3383
        for (z=0;z<m->m_laSingleMolIndex.GetSize();z++)
 
3384
        {
 
3385
                sm = (CSingleMolecule*)g_oaSingleMolecules[m->m_laSingleMolIndex[z]];
 
3386
                tf = sm->m_vDipole.GetLength();
 
3387
                if (tf > td)
 
3388
                        td = tf;
 
3389
                if (tf < td2)
 
3390
                        td2 = tf;
 
3391
                td3 += tf;
 
3392
        }
 
3393
        td3 /= (double)m->m_laSingleMolIndex.GetSize();
 
3394
 
 
3395
        mprintf("\n    Dipole moment of %s (1st step): Min. %.3f, Max. %.3f, Avg. %.3f Debye.\n\n",m->m_sName,td2,td,td3);
 
3396
 
 
3397
        switch(m_iDeriv)
 
3398
        {
 
3399
                case 0:
 
3400
                        m_fDipoleMin = AskFloat("    Enter the lower bound for dipole values (in Debye): [0] ",0.0f);
 
3401
                        m_fDipoleMax = AskFloat("    Enter the upper bound for dipole values (in Debye): [%d] ",float(int(td*2.0)),int(td*2.0));
 
3402
                        break;
 
3403
                case 1:
 
3404
                        if (m_bDerivAbs)
 
3405
                                m_fDipoleMin = AskFloat("    Enter the minimal value of this d1-DDF in Debye/ps: [0] ",0.0f);
 
3406
                                        else m_fDipoleMin = AskFloat("    Enter the minimal value of this d1-DDF in Debye/ps: [-10.0] ",-10.0f);
 
3407
                        m_fDipoleMax = AskFloat("    Enter the maximal value of this d1-DDF in Debye/ps: [10.0] ",10.0f);
 
3408
                        break;
 
3409
                case 2:
 
3410
                        if (m_bDerivAbs)
 
3411
                                m_fDipoleMin = AskFloat("    Enter the minimal value of this d2-DDF in Debye/ps^2: [0] ",0.0f);
 
3412
                                        else m_fDipoleMin = AskFloat("    Enter the minimal value of this d2-DDF in Debye/ps^2: [-10.0] ",-10.0f);
 
3413
                        m_fDipoleMax = AskFloat("    Enter the maximal value of this d2-DDF in Debye/ps^2: [10.0] ",10.0f);
 
3414
                        break;
 
3415
        }
 
3416
 
 
3417
        m_iResolution = AskUnsignedInteger("    Enter binning resolution for the Dipole DF: [%d] ",int((m_fDipoleMax-m_fDipoleMin)*10.0),int((m_fDipoleMax-m_fDipoleMin)*10.0));
 
3418
 
 
3419
        if (g_bAdvanced2)
 
3420
                m_iHistogramRes = AskUnsignedInteger("    Please enter histogram resolution (0=no histogram): [5000] ",5000);
 
3421
                        else m_iHistogramRes = 0;
 
3422
 
 
3423
        BuildName();
 
3424
        mprintf(WHITE,"\n<<< End of Dipole Distribution Function <<<\n\n");
 
3425
        BTOUT;
 
3426
}
 
3427
 
 
3428
 
 
3429
void CSDF::Parse(bool voro)
 
3430
{
 
3431
        BTIN;
 
3432
        int ti;
 
3433
        char buf[256];
 
3434
 
 
3435
        m_iShowAtomGes = 0;
 
3436
 
 
3437
        try { m_pSDF = new C3DF(); } catch(...) { m_pSDF = NULL; }
 
3438
        if (m_pSDF == NULL) NewException((double)sizeof(C3DF),__FILE__,__LINE__,__PRETTY_FUNCTION__);
 
3439
        
 
3440
        mprintf(WHITE,"\n>>> Spatial Distribution Function >>>\n\n");
 
3441
_sdfatoms:
 
3442
        if (!voro)
 
3443
        {
 
3444
                if (m_bIntra)
 
3445
                {
 
3446
                        mprintf("    Observing atoms in reference molecule %s.\n",((CMolecule*)g_oaMolecules[g_iFixMol])->m_sName);
 
3447
                        m_iRefOrSec = 0;
 
3448
                } else
 
3449
                {
 
3450
                        mprintf("    Observing atoms in observed molecule %s.\n",((CMolecule*)g_oaMolecules[m_iShowMol])->m_sName);
 
3451
                        m_iRefOrSec = 1;
 
3452
                }
 
3453
        /*      if (m_iShowMol != -1)
 
3454
                        m_iRefOrSec = AskRangeInteger("    Observe atoms in RM %s (0) or in OM %s (1)? [1] ",0,1,1,((CMolecule*)g_oaMolecules[g_iFixMol])->m_sName,((CMolecule*)g_oaMolecules[m_iShowMol])->m_sName);
 
3455
                                else m_iRefOrSec = 0;*/
 
3456
                mprintf("    Which atoms to observe (e.g. \"C1,C3-5,H\", \"*\"=all)? [#2] ");
 
3457
                inpprintf("! Which atoms to observe (e.g. \"C1,C3-5,H\", \"*\"=all)? [#2]\n");
 
3458
                myget(buf);
 
3459
                if (strlen(buf) == 0)
 
3460
                {
 
3461
                        if (!m_oAtoms.ParseAtoms((CMolecule*)g_oaMolecules[(m_iRefOrSec==0)?g_iFixMol:m_iShowMol],"#2"))
 
3462
                        {
 
3463
                                eprintf("Strange error ^^\n");
 
3464
                                inpprintf("! Strange error ^\n");
 
3465
                                goto _sdfatoms;
 
3466
                        }
 
3467
                } else 
 
3468
                {
 
3469
                        if (!m_oAtoms.ParseAtoms((CMolecule*)g_oaMolecules[(m_iRefOrSec==0)?g_iFixMol:m_iShowMol],buf))
 
3470
                        {
 
3471
                                eprintf("Wrong input.\n");
 
3472
                                inpprintf("! Wrong input.\n");
 
3473
                                goto _sdfatoms;
 
3474
                        }
 
3475
                }
 
3476
 
 
3477
                m_iShowAtomGes += m_oAtoms.m_iAtomGes;
 
3478
                m_fParticleDensity = m_oAtoms.m_iAtomGes * ((CMolecule*)g_oaMolecules[(m_iRefOrSec==0)?g_iFixMol:m_iShowMol])->m_laSingleMolIndex.GetSize() / g_fBoxX / g_fBoxY / g_fBoxZ * 1E9f;
 
3479
        }
 
3480
 
 
3481
        m_fRadius = AskFloat("    Please enter radius of this SDF in pm: [%d.0] ",(float)HalfBox(),HalfBox());
 
3482
_sdfresagain:
 
3483
        ti = g_pDatabase->GetInt("/PLOT3D/DEFAULTS/BIN_RES");
 
3484
        m_iResolution = AskUnsignedInteger("    Please enter binning resolution of this SDF per dimension: [%d] ",ti,ti);
 
3485
 
 
3486
        if (m_iResolution > 300)
 
3487
        {
 
3488
                eprintf("\nWarning: ");
 
3489
                mprintf("This large resolution will consume much RAM (%s)\n",FormatBytes(pow((double)m_iResolution,3)*sizeof(double)));
 
3490
                mprintf("         and result in very large SDF output files.\n\n");
 
3491
                if (!AskYesNo("    Use this resolution (y/n)? [no] ",false))
 
3492
                        goto _sdfresagain;
 
3493
        }
 
3494
 
 
3495
        if (g_bAdvanced2)
 
3496
        {
 
3497
                m_bVdWSpheres = false; //AskYesNo("    Process atoms as VdW spheres rather than points (y/n)? [no] ",false);
 
3498
                m_iHistogramRes = AskUnsignedInteger("    Please enter histogram resolution (0=no histogram): [5000] ",5000);
 
3499
                m_bClipPlane = AskYesNo("    Use a clipping plane for this SDF (y/n)? [no] ",false);
 
3500
                if (m_bClipPlane)
 
3501
                {
 
3502
        _cut:   mprintf("    Should the clipping plane stand perpendicular to the X, Y or Z axis (x/y/z)? [x] ");
 
3503
                        inpprintf("! Should the clipping plane stand perpendicular to the X, Y or Z axis (x/y/z)? [x]\n");
 
3504
                        myget(buf);
 
3505
                        switch(tolower(buf[0]))
 
3506
                        {
 
3507
                                case 0:
 
3508
                                case 'x':
 
3509
                                        m_iClipDirection = 0;
 
3510
                                        break;
 
3511
                                case 'y':
 
3512
                                        m_iClipDirection = 1;
 
3513
                                        break;
 
3514
                                case 'z':
 
3515
                                        m_iClipDirection = 2;
 
3516
                                        break;
 
3517
                                default:
 
3518
                                        eprintf("    Wrong input! Please enter 'x', 'y' or 'z'.\n");
 
3519
                                        inpprintf("! Wrong input! Please enter 'x', 'y' or 'z'.\n");
 
3520
                                        goto _cut;      
 
3521
                        }
 
3522
                        m_fClipValue = AskFloat("    Please enter distance of clipping plane from origin (in pm): [0] ",0.0f);
 
3523
                }
 
3524
                m_bInvert = AskYesNo("    Should this SDF be inverted (y/n)? [no] ",false);
 
3525
                m_bSDFMirrorXY = AskYesNo("    Force this SDF to be symmetrical to the XY plane (y/n)? [no] ",false);
 
3526
                m_bSDFMirrorBisect = AskYesNo("    Force this SDF to be symmetrical to the angle bisector (y/n)? [no] ",false);
 
3527
                m_bCutPlane = AskYesNo("    Add a particle density cut plane to this SDF (y/n)? [no] ",false);
 
3528
                if (m_bCutPlane)
 
3529
                {
 
3530
                        m_iCutPlaneResolution = AskUnsignedInteger("    Enter the binning resolution for the cut plane per dimension: [100] ",100);
 
3531
                        m_bCutPlaneShowAtoms = AskYesNo("    Show reference atoms in Pseudo SDF plot (y/n)? [yes] ",true);
 
3532
                }
 
3533
        } else
 
3534
        {
 
3535
                m_bVdWSpheres = false;
 
3536
                m_bClipPlane = false;
 
3537
                m_bInvert = false;
 
3538
                m_bSDFMirrorXY = false;
 
3539
                m_bSDFMirrorBisect = false;
 
3540
                m_bCutPlane = false;
3512
3541
                m_iHistogramRes = 0;
3513
 
                m_bClipPlane = false;
3514
 
                m_bInvert = false;
3515
 
                m_bSDFMirrorXY = false;
3516
 
                m_bSDFMirrorBisect = false;
3517
 
                m_bCutPlane = false;
3518
 
        }
3519
 
 
3520
 
        if (!voro)
3521
 
                BuildName();
3522
 
 
3523
 
        mprintf(WHITE,"\n<<< End of Spatial Distribution Function <<<\n\n");
3524
 
        BTOUT;
3525
 
}
3526
 
 
3527
 
 
3528
 
void CVDF::Parse()
3529
 
{
3530
 
        BTIN;
3531
 
        char buf[256];
3532
 
 
3533
 
        m_iShowAtomGes = 0;
3534
 
 
3535
 
        try { m_pVDF = new CDF(); } catch(...) { m_pVDF = NULL; }
3536
 
        if (m_pVDF == NULL) NewException((double)sizeof(CDF),__FILE__,__LINE__,__PRETTY_FUNCTION__);
3537
 
        
3538
 
        mprintf(WHITE,"\n>>> Velocity Distribution Function >>>\n\n");
3539
 
_atoms:
3540
 
        if (g_iFixMol == -1)
3541
 
        {
3542
 
                mprintf("    Observing atoms from OM %s.\n",((CMolecule*)g_oaMolecules[m_iShowMol])->m_sName);
3543
 
                m_iRefOrSec = 1;
3544
 
        } else if (m_iShowMol == -1)
3545
 
        {
3546
 
                mprintf("    Observing atoms from RM %s.\n",((CMolecule*)g_oaMolecules[g_iFixMol])->m_sName);
3547
 
                m_iRefOrSec = 0;
3548
 
        } else m_iRefOrSec = AskRangeInteger("    Observe atoms in RM %s (0) or in OM %s (1)? [1]",0,1,1,((CMolecule*)g_oaMolecules[g_iFixMol])->m_sName,((CMolecule*)g_oaMolecules[m_iShowMol])->m_sName);
3549
 
 
3550
 
        mprintf("    Which atoms to observe (e.g. \"C1,C3-5,H\", \"*\"=all)? [#2] ");
3551
 
        inpprintf("! Which atoms to observe (e.g. \"C1,C3-5,H\", \"*\"=all)? [#2]\n");
3552
 
        myget(buf);
3553
 
        if (strlen(buf) == 0)
3554
 
        {
3555
 
                m_oAtoms.AddAllAtoms((CMolecule*)g_oaMolecules[m_iRefOrSec?m_iShowMol:g_iFixMol],false);
3556
 
                if (!m_oAtoms.ParseAtoms((CMolecule*)g_oaMolecules[m_iRefOrSec?m_iShowMol:g_iFixMol],"#2"))
3557
 
                {
3558
 
                        eprintf("Strange error ^^\n");
3559
 
                        inpprintf("! Strange error ^^\n");
3560
 
                        goto _atoms;
3561
 
                }
3562
 
        } else 
3563
 
        {
3564
 
                if (!m_oAtoms.ParseAtoms((CMolecule*)g_oaMolecules[m_iRefOrSec?m_iShowMol:g_iFixMol],buf))
3565
 
                {
3566
 
                        eprintf("Wrong input.\n");
3567
 
                        inpprintf("! Wrong input.\n");
3568
 
                        goto _atoms;
3569
 
                }
3570
 
        }
3571
 
        m_iCombinations = m_oAtoms.m_iAtomGes;
3572
 
        m_iShowAtomGes += m_oAtoms.m_iAtomGes;
3573
 
//      m_fParticleDensity = m_oAtoms.m_iAtomGes * ((CMolecule*)g_oaMolecules[m_iShowMol])->m_laSingleMolIndex.GetSize() / g_fBoxX / g_fBoxY / g_fBoxZ;
3574
 
 
3575
 
        ParseDeriv();
3576
 
 
3577
 
        switch(m_iDeriv)
3578
 
        {
3579
 
                case 0:
3580
 
                /*      if (AskYesNo("    Scan for velocity range (y) or enter range manually (n)? [no] ",false))
3581
 
                        {
3582
 
                                m_bScanRange = true;
3583
 
                                g_bScanVelocities = true;
3584
 
                        } else*/
3585
 
                        {
3586
 
                                m_bScanRange = false;
3587
 
                                m_fMinSpeed = 0; //AskFloat("    Please enter the minimal velocity: [0.0 pm/fs] ",0.0f);
3588
 
                                m_fMaxSpeed = AskFloat("    Please enter the maximal velocity: [10000.0 pm/ps] ",10000.0f);
3589
 
                        }
3590
 
                        break;
3591
 
                case 1:
3592
 
                        if (m_bDerivAbs)
3593
 
                                m_fMinSpeed = AskFloat("    Enter the minimal value of this d1-VDF in pm/ps^2: [0] ",0.0f);
3594
 
                                        else m_fMinSpeed = AskFloat("    Enter the minimal value of this d1-VDF in pm/ps^2: [-10.0] ",-10.0f);
3595
 
                        m_fMaxSpeed = AskFloat("    Enter the maximal value of this d1-VDF in pm/ps^2: [10.0] ",10.0f);
3596
 
                        break;
3597
 
                case 2:
3598
 
                        if (m_bDerivAbs)
3599
 
                                m_fMinSpeed = AskFloat("    Enter the minimal value of this d2-VDF in pm/ps^3: [0] ",0.0f);
3600
 
                                        else m_fMinSpeed = AskFloat("    Enter the minimal value of this d2-VDF in pm/ps^3: [-10.0] ",-10.0f);
3601
 
                        m_fMaxSpeed = AskFloat("    Enter the maximal value of this d2-VDF in pm/ps^3: [10.0] ",10.0f);
3602
 
                        break;
3603
 
        }
3604
 
 
 
3542
        }
 
3543
 
 
3544
        if (!voro)
 
3545
                BuildName();
 
3546
 
 
3547
        mprintf(WHITE,"\n<<< End of Spatial Distribution Function <<<\n\n");
 
3548
        BTOUT;
 
3549
}
 
3550
 
 
3551
 
 
3552
void CVDF::Parse()
 
3553
{
 
3554
        BTIN;
 
3555
        char buf[256];
 
3556
 
 
3557
        m_iShowAtomGes = 0;
 
3558
 
 
3559
        try { m_pVDF = new CDF(); } catch(...) { m_pVDF = NULL; }
 
3560
        if (m_pVDF == NULL) NewException((double)sizeof(CDF),__FILE__,__LINE__,__PRETTY_FUNCTION__);
 
3561
        
 
3562
        mprintf(WHITE,"\n>>> Velocity Distribution Function >>>\n\n");
 
3563
_atoms:
 
3564
        if (g_iFixMol == -1)
 
3565
        {
 
3566
                mprintf("    Observing atoms from OM %s.\n",((CMolecule*)g_oaMolecules[m_iShowMol])->m_sName);
 
3567
                m_iRefOrSec = 1;
 
3568
        } else if (m_iShowMol == -1)
 
3569
        {
 
3570
                mprintf("    Observing atoms from RM %s.\n",((CMolecule*)g_oaMolecules[g_iFixMol])->m_sName);
 
3571
                m_iRefOrSec = 0;
 
3572
        } else m_iRefOrSec = AskRangeInteger("    Observe atoms in RM %s (0) or in OM %s (1)? [1]",0,1,1,((CMolecule*)g_oaMolecules[g_iFixMol])->m_sName,((CMolecule*)g_oaMolecules[m_iShowMol])->m_sName);
 
3573
 
 
3574
        mprintf("    Which atoms to observe (e.g. \"C1,C3-5,H\", \"*\"=all)? [#2] ");
 
3575
        inpprintf("! Which atoms to observe (e.g. \"C1,C3-5,H\", \"*\"=all)? [#2]\n");
 
3576
        myget(buf);
 
3577
        if (strlen(buf) == 0)
 
3578
        {
 
3579
                m_oAtoms.AddAllAtoms((CMolecule*)g_oaMolecules[m_iRefOrSec?m_iShowMol:g_iFixMol],false);
 
3580
                if (!m_oAtoms.ParseAtoms((CMolecule*)g_oaMolecules[m_iRefOrSec?m_iShowMol:g_iFixMol],"#2"))
 
3581
                {
 
3582
                        eprintf("Strange error ^^\n");
 
3583
                        inpprintf("! Strange error ^^\n");
 
3584
                        goto _atoms;
 
3585
                }
 
3586
        } else 
 
3587
        {
 
3588
                if (!m_oAtoms.ParseAtoms((CMolecule*)g_oaMolecules[m_iRefOrSec?m_iShowMol:g_iFixMol],buf))
 
3589
                {
 
3590
                        eprintf("Wrong input.\n");
 
3591
                        inpprintf("! Wrong input.\n");
 
3592
                        goto _atoms;
 
3593
                }
 
3594
        }
 
3595
        m_iCombinations = m_oAtoms.m_iAtomGes;
 
3596
        m_iShowAtomGes += m_oAtoms.m_iAtomGes;
 
3597
//      m_fParticleDensity = m_oAtoms.m_iAtomGes * ((CMolecule*)g_oaMolecules[m_iShowMol])->m_laSingleMolIndex.GetSize() / g_fBoxX / g_fBoxY / g_fBoxZ;
 
3598
 
 
3599
        ParseDeriv();
 
3600
 
 
3601
        switch(m_iDeriv)
 
3602
        {
 
3603
                case 0:
 
3604
                /*      if (AskYesNo("    Scan for velocity range (y) or enter range manually (n)? [no] ",false))
 
3605
                        {
 
3606
                                m_bScanRange = true;
 
3607
                                g_bScanVelocities = true;
 
3608
                        } else*/
 
3609
                        {
 
3610
                                m_bScanRange = false;
 
3611
                                m_fMinSpeed = 0; //AskFloat("    Please enter the minimal velocity: [0.0 pm/fs] ",0.0f);
 
3612
                                m_fMaxSpeed = AskFloat("    Please enter the maximal velocity: [10000.0 pm/ps] ",10000.0f);
 
3613
                        }
 
3614
                        break;
 
3615
                case 1:
 
3616
                        if (m_bDerivAbs)
 
3617
                                m_fMinSpeed = AskFloat("    Enter the minimal value of this d1-VDF in pm/ps^2: [0] ",0.0f);
 
3618
                                        else m_fMinSpeed = AskFloat("    Enter the minimal value of this d1-VDF in pm/ps^2: [-10.0] ",-10.0f);
 
3619
                        m_fMaxSpeed = AskFloat("    Enter the maximal value of this d1-VDF in pm/ps^2: [10.0] ",10.0f);
 
3620
                        break;
 
3621
                case 2:
 
3622
                        if (m_bDerivAbs)
 
3623
                                m_fMinSpeed = AskFloat("    Enter the minimal value of this d2-VDF in pm/ps^3: [0] ",0.0f);
 
3624
                                        else m_fMinSpeed = AskFloat("    Enter the minimal value of this d2-VDF in pm/ps^3: [-10.0] ",-10.0f);
 
3625
                        m_fMaxSpeed = AskFloat("    Enter the maximal value of this d2-VDF in pm/ps^3: [10.0] ",10.0f);
 
3626
                        break;
 
3627
        }
 
3628
 
3605
3629
        m_iResolution = AskInteger("    Please enter the binning resolution for this VDF: [300] ",300);
3606
 
        if (g_bAdvanced2)
3607
 
                m_iHistogramRes = AskUnsignedInteger("    Please enter histogram resolution (0=no histogram): [5000] ",5000);
3608
 
        else m_iHistogramRes = 0;
3609
 
/*      mprintf("    Save temporal Development of Velocity (0=no, 1=yes)? [0] ");
3610
 
        myget(buf);
3611
 
        m_bSaveSpeed = atoi(buf)!=0;*/
3612
 
        BuildName();
3613
 
        mprintf(WHITE,"\n<<< End of Velocity Distribution Function <<<\n\n");
3614
 
        BTOUT;
3615
 
}
3616
 
 
3617
 
 
3618
 
void CSDF::BuildName()
3619
 
{
3620
 
        BTIN;
3621
 
        char tmp[256];
3622
 
 
3623
 
        tmp[0] = 0;
3624
 
 
3625
 
        if (m_iRefOrSec)
3626
 
                sprintf(tmp,"%s_%s%d%s%d%s%d_%s_%s",((CMolecule*)g_oaMolecules[g_iFixMol])->m_sName,((CAtom*)g_oaAtoms[g_iFixRealAtomType[0]])->m_sName,g_iFixAtom[0]+1,((CAtom*)g_oaAtoms[g_iFixRealAtomType[1]])->m_sName,g_iFixAtom[1]+1,((CAtom*)g_oaAtoms[g_iFixRealAtomType[2]])->m_sName,g_iFixAtom[2]+1,((CMolecule*)g_oaMolecules[m_iShowMol])->m_sName,m_oAtoms.m_sName);
3627
 
                        else sprintf(tmp,"%s_%s%d%s%d%s%d_%s",((CMolecule*)g_oaMolecules[g_iFixMol])->m_sName,((CAtom*)g_oaAtoms[g_iFixRealAtomType[0]])->m_sName,g_iFixAtom[0]+1,((CAtom*)g_oaAtoms[g_iFixRealAtomType[1]])->m_sName,g_iFixAtom[1]+1,((CAtom*)g_oaAtoms[g_iFixRealAtomType[2]])->m_sName,g_iFixAtom[2]+1,m_oAtoms.m_sName);
3628
 
 
3629
 
        try { m_sName = new char[strlen(tmp)+1]; } catch(...) { m_sName = NULL; }
3630
 
        if (m_sName == NULL) NewException((double)(strlen(tmp)+1)*sizeof(char),__FILE__,__LINE__,__PRETTY_FUNCTION__);
3631
 
        
3632
 
        strcpy(m_sName,tmp);
3633
 
        BTOUT;
3634
 
}
3635
 
 
3636
 
 
3637
 
void CVDF::BuildName()
3638
 
{
3639
 
        BTIN;
3640
 
        char tmp[256];
3641
 
 
3642
 
        if (m_iDeriv != 0)
3643
 
                sprintf(tmp,"deriv%d_%s",m_iDeriv,m_oAtoms.m_sName);
3644
 
                        else sprintf(tmp,"%s",m_oAtoms.m_sName);
3645
 
 
3646
 
        try { m_sShortName = new char[strlen(tmp)+1]; } catch(...) { m_sShortName = NULL; }
3647
 
        if (m_sShortName == NULL) NewException((double)(strlen(tmp)+1)*sizeof(char),__FILE__,__LINE__,__PRETTY_FUNCTION__);
3648
 
        
3649
 
        strcpy(m_sShortName,m_oAtoms.m_sName);
3650
 
        if (g_iFixMol == -1)
3651
 
        {
3652
 
                sprintf(tmp,"%s_",((CMolecule*)g_oaMolecules[m_iShowMol])->m_sName);
3653
 
        } else if (m_iRefOrSec)
3654
 
                sprintf(tmp,"%s_%s%d_%s_",((CMolecule*)g_oaMolecules[g_iFixMol])->m_sName,((CAtom*)g_oaAtoms[g_iFixRealAtomType[0]])->m_sName,g_iFixAtom[0]+1,((CMolecule*)g_oaMolecules[m_iShowMol])->m_sName);
3655
 
                        else sprintf(tmp,"%s_%s%d_",((CMolecule*)g_oaMolecules[g_iFixMol])->m_sName,((CAtom*)g_oaAtoms[g_iFixRealAtomType[0]])->m_sName,g_iFixAtom[0]+1);
3656
 
        strcat(tmp,m_sShortName);
3657
 
 
3658
 
        try { m_sName = new char[strlen(tmp)+1]; } catch(...) { m_sName = NULL; }
3659
 
        if (m_sName == NULL) NewException((double)(strlen(tmp)+1)*sizeof(char),__FILE__,__LINE__,__PRETTY_FUNCTION__);
3660
 
        
3661
 
        strcpy(m_sName,tmp);
3662
 
        BTOUT;
3663
 
}
3664
 
 
3665
 
 
3666
 
void CSDF::BuildAtomList(CSingleMolecule *ref, CSingleMolecule *obs, CxIntArray *vec)
3667
 
{
3668
 
        BXIN;
3669
 
        int z1t, z1a;
3670
 
        CxIntArray *a1;
3671
 
 
3672
 
        vec->RemoveAll_KeepSize();
3673
 
        for (z1t=0;z1t<m_oAtoms.m_baAtomType.GetSize();z1t++)
3674
 
        {
3675
 
//              mprintf("(a) BuildAtomList z1t=%d, WA=%X\n",z1t,m_oAtoms.m_oaAtoms[z1t]);
3676
 
                a1 = (CxIntArray*)m_oAtoms.m_oaAtoms[z1t];
3677
 
//              mprintf("(b) BuildAtomList wa.GetSize()=%d\n",a1->GetSize());
3678
 
                for (z1a=0;z1a<a1->GetSize();z1a++)
3679
 
                        if (m_iRefOrSec)
3680
 
                        {
3681
 
//                              mprintf("(c) BuildAtomList z1t=%d, z1a=%d, Type=%d, WA=%X\n",z1t,z1a,m_oAtoms.m_baAtomType[z1t],obs->m_oaAtomOffset[m_oAtoms.m_baAtomType[z1t]]);
3682
 
                                vec->Add(((CxIntArray*)obs->m_oaAtomOffset[m_oAtoms.m_baAtomType[z1t]])->GetAt(a1->GetAt(z1a)));
3683
 
                        } else vec->Add(((CxIntArray*)ref->m_oaAtomOffset[m_oAtoms.m_baAtomType[z1t]])->GetAt(a1->GetAt(z1a)));
3684
 
        }
3685
 
        BXOUT;
3686
 
}
3687
 
 
3688
 
 
3689
 
void CVDF::BuildAtomList(CSingleMolecule *ref, CSingleMolecule *obs, CxIntArray *vec)
3690
 
{
3691
 
        BXIN;
3692
 
        int z1t, z1a;
3693
 
        CxIntArray *a1;
3694
 
 
3695
 
        vec->RemoveAll_KeepSize();
3696
 
        for (z1t=0;z1t<m_oAtoms.m_baAtomType.GetSize();z1t++)
3697
 
        {
3698
 
                a1 = (CxIntArray*)m_oAtoms.m_oaAtoms[z1t];
3699
 
                for (z1a=0;z1a<a1->GetSize();z1a++)
3700
 
                        if (m_iRefOrSec)
3701
 
                                vec->Add(((CxIntArray*)obs->m_oaAtomOffset[m_oAtoms.m_baAtomType[z1t]])->GetAt(a1->GetAt(z1a)));
3702
 
                                        else vec->Add(((CxIntArray*)ref->m_oaAtomOffset[m_oAtoms.m_baAtomType[z1t]])->GetAt(a1->GetAt(z1a)));
3703
 
        }
3704
 
        BXOUT;
3705
 
}
3706
 
 
3707
 
 
3708
 
void CRDF::BuildAtomList(CSingleMolecule *ref, CSingleMolecule *obs, CxIntArray *vec)
3709
 
{
3710
 
        BXIN;
3711
 
        int z, z1t, z1a, z2t, z2a;
3712
 
        CAtomGroup *g1, *g2;
3713
 
        CxIntArray *a1, *a2;
3714
 
 
3715
 
        vec->RemoveAll_KeepSize();
3716
 
        for (z=0;z<m_oaVectors.GetSize()/2;z++)
3717
 
        {
3718
 
                g1 = (CAtomGroup*)m_oaVectors[z*2];
3719
 
                for (z1t=0;z1t<g1->m_baAtomType.GetSize();z1t++)
3720
 
                {
3721
 
                        a1 = (CxIntArray*)g1->m_oaAtoms[z1t];
3722
 
                        for (z1a=0;z1a<a1->GetSize();z1a++)
3723
 
                        {
3724
 
                                g2 = (CAtomGroup*)m_oaVectors[z*2+1];
3725
 
                                for (z2t=0;z2t<g2->m_baAtomType.GetSize();z2t++)
3726
 
                                {
3727
 
                                        a2 = (CxIntArray*)g2->m_oaAtoms[z2t];
3728
 
                                        for (z2a=0;z2a<a2->GetSize();z2a++)
3729
 
                                        {
3730
 
                                                if (m_iRefOrSec[0])
3731
 
                                                        vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g1->m_baAtomType[z1t]])->GetAt(a1->GetAt(z1a)));
3732
 
                                                                else vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g1->m_baAtomType[z1t]])->GetAt(a1->GetAt(z1a)));
3733
 
                                                if (m_iRefOrSec[1])
3734
 
                                                        vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g2->m_baAtomType[z2t]])->GetAt(a2->GetAt(z2a)));
3735
 
                                                                else vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g2->m_baAtomType[z2t]])->GetAt(a2->GetAt(z2a)));
3736
 
                        //                      mprintf("Vector z=%d, z1t=%d, z1a=%d, z2t=%d, z2a=%d.\n",z,z1t,z1a,z2t,z2a);
3737
 
                                        }
3738
 
                                }
3739
 
                        }
3740
 
                }
3741
 
        }
3742
 
        BXOUT;
3743
 
}
3744
 
 
3745
 
 
3746
 
void CVHDF::BuildAtomList(CSingleMolecule *ref, CSingleMolecule *obs, CxIntArray *vec)
3747
 
{
3748
 
        BXIN;
3749
 
        int z, z1t, z1a, z2t, z2a;
3750
 
        CAtomGroup *g1, *g2;
3751
 
        CxIntArray *a1, *a2;
3752
 
 
3753
 
        vec->RemoveAll_KeepSize();
3754
 
        for (z=0;z<m_oaVectors.GetSize()/2;z++)
3755
 
        {
3756
 
                g1 = (CAtomGroup*)m_oaVectors[z*2];
3757
 
                for (z1t=0;z1t<g1->m_baAtomType.GetSize();z1t++)
3758
 
                {
3759
 
                        a1 = (CxIntArray*)g1->m_oaAtoms[z1t];
3760
 
                        for (z1a=0;z1a<a1->GetSize();z1a++)
3761
 
                        {
3762
 
                                g2 = (CAtomGroup*)m_oaVectors[z*2+1];
3763
 
                                for (z2t=0;z2t<g2->m_baAtomType.GetSize();z2t++)
3764
 
                                {
3765
 
                                        a2 = (CxIntArray*)g2->m_oaAtoms[z2t];
3766
 
                                        for (z2a=0;z2a<a2->GetSize();z2a++)
3767
 
                                        {
3768
 
                                                if (m_iRefOrSec[0])
3769
 
                                                        vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g1->m_baAtomType[z1t]])->GetAt(a1->GetAt(z1a)));
3770
 
                                                                else vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g1->m_baAtomType[z1t]])->GetAt(a1->GetAt(z1a)));
3771
 
                                                if (m_iRefOrSec[1])
3772
 
                                                        vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g2->m_baAtomType[z2t]])->GetAt(a2->GetAt(z2a)));
3773
 
                                                                else vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g2->m_baAtomType[z2t]])->GetAt(a2->GetAt(z2a)));
3774
 
                                        }
3775
 
                                }
3776
 
                        }
3777
 
                }
3778
 
        }
3779
 
        BXOUT;
3780
 
}
3781
 
 
3782
 
 
3783
 
/*int FindAtom(char *s)
3784
 
{
3785
 
        BTIN;
3786
 
        int z;
3787
 
        for (z=0;z<g_oaAtoms.GetSize();z++)
3788
 
                if (mystricmp(s,((CAtom*)g_oaAtoms[z])->m_sName)==0)
3789
 
                {
3790
 
                        BTOUT; 
3791
 
                        return z;
3792
 
                }
3793
 
        BTOUT; 
3794
 
        return -1;
3795
 
}*/
3796
 
 
3797
 
 
3798
 
int CMolecule::FindAtomInMol(const char *s)
3799
 
{
3800
 
        BTIN;
3801
 
        int z;
3802
 
        for (z=0;z<m_baAtomIndex.GetSize();z++)
3803
 
                if (mystricmp(s,((CAtom*)g_oaAtoms[m_baAtomIndex[z]])->m_sName)==0)
3804
 
                {
3805
 
                        BTOUT; 
3806
 
                        return z;
3807
 
                }
3808
 
        BTOUT; 
3809
 
        return -1;
3810
 
}
3811
 
 
3812
 
 
3813
 
void CMolecule::BuildName()
3814
 
{
3815
 
        BTIN;
3816
 
        int z, z2;
3817
 
        char buf[16], buf2[256];
3818
 
 
3819
 
        if (m_bPseudo)
3820
 
        {
3821
 
                buf2[0] = '$';
3822
 
                buf2[1] = 0;
3823
 
        } else buf2[0] = 0;
3824
 
        for (z=0;z<g_oaAtoms.GetSize();z++)
3825
 
        {
3826
 
                for (z2=0;z2<m_baAtomIndex.GetSize();z2++)
3827
 
                {
3828
 
                        if (m_baAtomIndex[z2] != z)
3829
 
                                continue;
3830
 
                        if (m_waAtomCount[z2] > 1)
3831
 
                                sprintf(buf,"%s%d",((CAtom*)g_oaAtoms[z])->m_sName,m_waAtomCount[z2]);
3832
 
                        else sprintf(buf,"%s",((CAtom*)g_oaAtoms[z])->m_sName);
3833
 
                        strcat(buf2,buf);
3834
 
                }
3835
 
        }
3836
 
 
3837
 
        try { m_sName = new char[strlen(buf2)+1]; } catch(...) { m_sName = NULL; }
3838
 
        if (m_sName == NULL) NewException((double)(strlen(buf2)+1)*sizeof(char),__FILE__,__LINE__,__PRETTY_FUNCTION__);
3839
 
        
3840
 
        strcpy(m_sName,buf2);
3841
 
        BTOUT; 
3842
 
}
3843
 
 
3844
 
 
3845
 
bool CConditionGroup::Contains(int mol)
3846
 
{
3847
 
        BXIN;
3848
 
        int z;
3849
 
 
3850
 
        if (m_bInactive)
3851
 
                return m_bAlwaysTrue[mol];
3852
 
 
3853
 
        if (m_bInvertCondition)
3854
 
        {
3855
 
                if (m_bAlwaysTrue[mol])
3856
 
                {
3857
 
                        BXOUT;
3858
 
                        return false;
3859
 
                }
3860
 
                for (z=0;z<m_oaConditionSubGroups.GetSize();z++)
3861
 
                {
3862
 
                        if (((CConditionSubGroup*)m_oaConditionSubGroups[z])->Contains(mol))
3863
 
                        {
3864
 
                                BXOUT;
3865
 
                                return false;
3866
 
                        }
3867
 
                }
3868
 
                BXOUT;
3869
 
                return true;
3870
 
        } else
3871
 
        {
3872
 
                if (m_bAlwaysTrue[mol])
3873
 
                {
3874
 
                        BXOUT;
3875
 
                        return true;
3876
 
                }
3877
 
                for (z=0;z<m_oaConditionSubGroups.GetSize();z++)
3878
 
                {
3879
 
                        if (((CConditionSubGroup*)m_oaConditionSubGroups[z])->Contains(mol))
3880
 
                        {
3881
 
                                BXOUT;
3882
 
                                return true;
3883
 
                        }
3884
 
                }
3885
 
                BXOUT;
3886
 
                return false;
3887
 
        }
3888
 
}
3889
 
 
3890
 
 
3891
 
void CConditionGroup::MarkPassedAtoms(int om, bool passed)
3892
 
{
3893
 
        BXIN;
3894
 
        int z;
3895
 
//      int ti;
3896
 
 
3897
 
//      mprintf("######## OM %d ##########\n",om+1);
3898
 
 
3899
 
        for (z=0;z<g_iGesVirtAtomCount;z++)
3900
 
                g_baAtomPassedCondition[z] = 110; // 110 heisst: Atom kommt nicht in einer Condition vor
3901
 
 
3902
 
        for (z=0;z<m_oaConditionSubGroups.GetSize();z++)
3903
 
                ((CConditionSubGroup*)m_oaConditionSubGroups[z])->MarkPassedAtoms(om);
3904
 
 
3905
 
//      for (z=0;z<g_iGesVirtAtomCount;z++)
3906
 
//              mprintf("\nAtom %d: %d.",z+1,g_baAtomPassedCondition[z]);
3907
 
 
3908
 
//      ti = 0;
3909
 
        if (m_bInvertCondition)
3910
 
        {
3911
 
                for (z=0;z<g_iGesVirtAtomCount;z++)
3912
 
                {
3913
 
                        if (g_baAtomPassedCondition[z] != 100) // Entweder Condition nicht bestanden oder Atom kam gar nicht darin vor
3914
 
                        {
3915
 
//                              ti++;
3916
 
                                g_baAtomPassedCondition[z] = 1;
3917
 
//                              mprintf("%d: Ok\n",z+1);
3918
 
//                              mprintf("\n %d --> Wird genommen.",z+1);
3919
 
                        } else // Condition bestanden
3920
 
                        {
3921
 
        //                      mprintf("Atom %s%d nicht bestanden (%d).\n",((CAtom*)g_oaAtoms[g_waAtomRealElement[z]])->m_sName,g_waAtomMolNumber[z]+1,g_baAtomPassedCondition[z]);
3922
 
        //                      mprintf("\n%d erfuellt --> durchgefallen",z+1);
3923
 
                                g_baAtomPassedCondition[z] = 0;
3924
 
                        }
3925
 
                }
3926
 
        } else
3927
 
        {
3928
 
                for (z=0;z<g_iGesVirtAtomCount;z++)
3929
 
                {
3930
 
                        if (passed)
3931
 
                        {
3932
 
                                if (g_baAtomPassedCondition[z] >= 100) // Entweder Condition bestanden oder Atom kam gar nicht darin vor
3933
 
                                {
3934
 
//                                      ti++;
3935
 
                                        g_baAtomPassedCondition[z] = 1;
3936
 
                                } else // Condition nicht bestanden
3937
 
                                {
3938
 
                //                      mprintf("Atom %s%d nicht bestanden (%d).\n",((CAtom*)g_oaAtoms[g_waAtomRealElement[z]])->m_sName,g_waAtomMolNumber[z]+1,g_baAtomPassedCondition[z]);
3939
 
                                        g_baAtomPassedCondition[z] = 0;
3940
 
                                }
3941
 
                        } else
3942
 
                        {
3943
 
                                if (g_baAtomPassedCondition[z] == 100) // Condition bestanden
3944
 
                                {
3945
 
//                                      ti++;
3946
 
//                                      mprintf("### Atom %s[%d] %s%d bestanden (%d).\n",((CMolecule*)g_oaMolecules[g_waAtomMolIndex[z]])->m_sName,g_laAtomSMLocalIndex[z]+1,((CAtom*)g_oaAtoms[g_waAtomRealElement[z]])->m_sName,g_waAtomMolNumber[z]+1,g_baAtomPassedCondition[z]);
3947
 
                                        g_baAtomPassedCondition[z] = 0;
3948
 
                                } else // Entweder Condition nicht bestanden oder Atom kam gar nicht darin vor
3949
 
                                {
3950
 
//                                      mprintf("--- Atom %s[%d] %s%d nicht bestanden (%d).\n",((CMolecule*)g_oaMolecules[g_waAtomMolIndex[z]])->m_sName,g_laAtomSMLocalIndex[z]+1,((CAtom*)g_oaAtoms[g_waAtomRealElement[z]])->m_sName,g_waAtomMolNumber[z]+1,g_baAtomPassedCondition[z]);
3951
 
                                        g_baAtomPassedCondition[z] = 1;
3952
 
                                }
3953
 
                        }
3954
 
                }
3955
 
        }
3956
 
//      mprintf("\nMarked %d / %d atoms as enabled.",ti,g_iGesVirtAtomCount);
3957
 
 
3958
 
        BXOUT;
3959
 
}
3960
 
 
3961
 
 
3962
 
void CConditionGroup::ScanNeighborhoodAllOM(CTimeStep *t, CSingleMolecule *rm)
3963
 
{
3964
 
        BXIN;
3965
 
        int z, z2, t1, t2, i;
3966
 
 
3967
 
        if (m_bInactive)
3968
 
                return;
3969
 
 
3970
 
        for (z=0;z<m_oaConditionSubGroups.GetSize();z++)
3971
 
                ((CConditionSubGroup*)m_oaConditionSubGroups[z])->ScanNeighborhoodAllOM(t,rm);
3972
 
 
3973
 
        if (m_oaConditionSubGroups.GetSize() == 2)
3974
 
        {
3975
 
                for (z=0;z<((CMolecule*)g_oaMolecules[m_iShowMol])->m_laSingleMolIndex.GetSize();z++)
3976
 
                {
3977
 
                        t1 = 0;
3978
 
                        t2 = 0;
3979
 
                        for (z2=0;z2<((CConditionSubGroup*)m_oaConditionSubGroups[0])->m_oaConditions.GetSize();z2++)
3980
 
                                t1 += ((CNbSearch*)((CConditionSubGroup*)m_oaConditionSubGroups[0])->m_oaConditions[z2])->m_iCombPassCount[z];
3981
 
                        for (z2=0;z2<((CConditionSubGroup*)m_oaConditionSubGroups[1])->m_oaConditions.GetSize();z2++)
3982
 
                                t2 += ((CNbSearch*)((CConditionSubGroup*)m_oaConditionSubGroups[1])->m_oaConditions[z2])->m_iCombPassCount[z];
3983
 
                        m_pTable[t1*(((CConditionSubGroup*)m_oaConditionSubGroups[1])->m_iCombinations+1)+t2]++;
3984
 
                        m_fTableGes++;
3985
 
                }
3986
 
        }
3987
 
 
3988
 
        i = 0;
3989
 
        for (z=0;z<((CMolecule*)g_oaMolecules[m_iShowMol])->m_laSingleMolIndex.GetSize();z++)
3990
 
        {
3991
 
                m_fTotal++;
3992
 
                if (m_bInvertCondition)
3993
 
                {
3994
 
                        for (z2=0;z2<m_oaConditionSubGroups.GetSize();z2++)
3995
 
                                if (((CConditionSubGroup*)m_oaConditionSubGroups[z2])->Contains(z))
3996
 
                                        goto _nopass;
3997
 
                        m_fPassed++;
3998
 
                        m_iPassCounter[z]++;
3999
 
                        m_bAnyPassed = true;
4000
 
                } else
4001
 
                {
4002
 
                        for (z2=0;z2<m_oaConditionSubGroups.GetSize();z2++)
4003
 
                        {
4004
 
                                if (((CConditionSubGroup*)m_oaConditionSubGroups[z2])->Contains(z))
4005
 
                                {
4006
 
//                                      mprintf("passed[%d]++\n",z);
4007
 
                                        m_fPassed++;
4008
 
                                        m_iPassCounter[z]++;
4009
 
                                        m_bAnyPassed = true;
4010
 
                                        i++;
4011
 
                                        goto _nopass;
4012
 
                                }
4013
 
                        }
4014
 
                }
4015
 
_nopass:;
4016
 
        }
4017
 
        m_pHistogram[i]++;
4018
 
        m_iHistoGes++;
4019
 
 
4020
 
        BXOUT;
4021
 
}
4022
 
 
4023
 
 
4024
 
void CConditionGroup::PreScanNeighborhoodAllOM(CTimeStep *t, CSingleMolecule *rm)
4025
 
{
4026
 
        BXIN;
4027
 
        int z;
4028
 
 
4029
 
        if (m_bInactive)
4030
 
                return;
4031
 
 
4032
 
        for (z=0;z<m_oaConditionSubGroups.GetSize();z++)
4033
 
                ((CConditionSubGroup*)m_oaConditionSubGroups[z])->PreScanNeighborhoodAllOM(t,rm);
4034
 
 
4035
 
        BXOUT;
4036
 
}
4037
 
 
4038
 
 
4039
 
void CConditionGroup::Parse(int rm, int sm)
4040
 
{
4041
 
        BTIN;
4042
 
        CConditionSubGroup *sg;
4043
 
        int z;
4044
 
 
4045
 
        m_iShowMol = sm;
4046
 
        m_iRefMol = rm;
4047
 
 
4048
 
        try { m_bAlwaysTrue = new bool[((CMolecule*)g_oaMolecules[sm])->m_laSingleMolIndex.GetSize()]; } catch(...) { m_bAlwaysTrue = NULL; }
4049
 
        if (m_bAlwaysTrue == NULL) NewException((double)((CMolecule*)g_oaMolecules[sm])->m_laSingleMolIndex.GetSize()*sizeof(bool),__FILE__,__LINE__,__PRETTY_FUNCTION__);
4050
 
        
4051
 
        try { m_iPassCounter = new long[((CMolecule*)g_oaMolecules[sm])->m_laSingleMolIndex.GetSize()]; } catch(...) { m_iPassCounter = NULL; }
4052
 
        if (m_iPassCounter == NULL) NewException((double)((CMolecule*)g_oaMolecules[sm])->m_laSingleMolIndex.GetSize()*sizeof(long),__FILE__,__LINE__,__PRETTY_FUNCTION__);
4053
 
        
4054
 
        try { m_iOMPassCounter = new long[((CMolecule*)g_oaMolecules[sm])->m_laSingleMolIndex.GetSize()]; } catch(...) { m_iOMPassCounter = NULL; }
4055
 
        if (m_iOMPassCounter == NULL) NewException((double)((CMolecule*)g_oaMolecules[sm])->m_laSingleMolIndex.GetSize()*sizeof(long),__FILE__,__LINE__,__PRETTY_FUNCTION__);
4056
 
        
4057
 
        for (z=0;z<((CMolecule*)g_oaMolecules[sm])->m_laSingleMolIndex.GetSize();z++)
4058
 
        {
4059
 
                m_bAlwaysTrue[z] = false;
4060
 
                m_iPassCounter[z] = 0;
4061
 
                m_iOMPassCounter[z] = 0;
4062
 
        }
4063
 
 
4064
 
        try { m_iRMPassCounter = new long[((CMolecule*)g_oaMolecules[rm])->m_laSingleMolIndex.GetSize()]; } catch(...) { m_iRMPassCounter = NULL; }
4065
 
        if (m_iRMPassCounter == NULL) NewException((double)((CMolecule*)g_oaMolecules[rm])->m_laSingleMolIndex.GetSize()*sizeof(long),__FILE__,__LINE__,__PRETTY_FUNCTION__);
4066
 
        
4067
 
        for (z=0;z<((CMolecule*)g_oaMolecules[rm])->m_laSingleMolIndex.GetSize();z++)
4068
 
                m_iRMPassCounter[z] = 0;
4069
 
 
4070
 
        mprintf("Different sets of conditions are connected with OR (at least one of them has to be fulfilled).\n");
4071
 
        mprintf("Different conditions within one set are connected with AND (have to be fulfilled at the same time).\n");
4072
 
        mprintf("If you create 1 or 2 sets of conditions, a table with subcondition count populations will be printed.\n\n");
4073
 
_newset:
4074
 
        mprintf(YELLOW,">>> %d. set of conditions >>>\n",m_oaConditionSubGroups.GetSize()+1);
4075
 
 
4076
 
        try { sg = new CConditionSubGroup(); } catch(...) { sg = NULL; }
4077
 
        if (sg == NULL) NewException((double)sizeof(CConditionSubGroup),__FILE__,__LINE__,__PRETTY_FUNCTION__);
4078
 
        
4079
 
        sg->m_iShowMol = m_iShowMol;
4080
 
        sg->m_iNumber = m_oaConditionSubGroups.GetSize();
4081
 
        m_oaConditionSubGroups.Add(sg);
4082
 
        sg->Parse(rm,sm);
4083
 
        mprintf(YELLOW,"\n<<< End of %d. set of conditions <<<\n\n",m_oaConditionSubGroups.GetSize());
4084
 
        if (AskYesNo("    Enter an additional set of conditions (y/n)? [no] ",false))
4085
 
                goto _newset;
4086
 
        
4087
 
        m_bInvertCondition = AskYesNo("    Invert this condition (only add bin entries if failed) (y/n)? [no] ",false);
4088
 
 
4089
 
        if (m_oaConditionSubGroups.GetSize() == 2)
4090
 
        {
4091
 
                m_fTableGes = 0;
4092
 
 
4093
 
                try { m_pTable = new double[(((CConditionSubGroup*)m_oaConditionSubGroups[0])->m_iCombinations+1) * (((CConditionSubGroup*)m_oaConditionSubGroups[1])->m_iCombinations+1)]; } catch(...) { m_pTable = NULL; }
4094
 
                if (m_pTable == NULL) NewException((double)(((CConditionSubGroup*)m_oaConditionSubGroups[0])->m_iCombinations+1) * (((CConditionSubGroup*)m_oaConditionSubGroups[1])->m_iCombinations+1)*sizeof(double),__FILE__,__LINE__,__PRETTY_FUNCTION__);
4095
 
                
4096
 
                for (z=0;z<(((CConditionSubGroup*)m_oaConditionSubGroups[0])->m_iCombinations+1) * (((CConditionSubGroup*)m_oaConditionSubGroups[1])->m_iCombinations+1);z++)
4097
 
                        m_pTable[z] = 0;
4098
 
        }
4099
 
 
4100
 
/*      m_bNeedNbCountMode = false;
4101
 
        for (z=0;z<m_oaConditionSubGroups.GetSize();z++)
4102
 
        {
4103
 
                sg = (CConditionSubGroup*)m_oaConditionSubGroups[z];
4104
 
                for (z2=0;z2<sg->m_oaConditions.GetSize();z2++)
4105
 
                        if (((CNbSearch*)sg->m_oaConditions[z2])->m_iNbCountMin != -1)
4106
 
                                m_bNeedNbCountMode = true;
4107
 
        }*/
4108
 
        m_iHistoGes = 0;
4109
 
 
4110
 
        try {m_pHistogram = new unsigned long[((CMolecule*)g_oaMolecules[sm])->m_laSingleMolIndex.GetSize()+1]; } catch(...) { m_pHistogram = NULL; }
4111
 
        if (m_pHistogram == NULL) NewException((double)((CMolecule*)g_oaMolecules[sm])->m_laSingleMolIndex.GetSize()+1*sizeof(unsigned long),__FILE__,__LINE__,__PRETTY_FUNCTION__);
4112
 
        
4113
 
        for (z=0;z<((CMolecule*)g_oaMolecules[sm])->m_laSingleMolIndex.GetSize()+1;z++)
4114
 
                m_pHistogram[z] = 0;
4115
 
        BTOUT;
4116
 
}
4117
 
 
4118
 
 
4119
 
void CConditionGroup::PrintData()
4120
 
{
4121
 
        int z;
4122
 
 
4123
 
        mprintf(GREEN,"\n>>> Condition Data >>>\n\n");
4124
 
        mprintf("    %.0f of %.0f molecules passed the conditions (%.2f percent).\n",m_fPassed,m_fTotal,ZeroDivide(m_fPassed,m_fTotal)*100.0f);
4125
 
        if (m_fPassed == 0)
4126
 
        {
4127
 
                mprintf(YELLOW,"\n    No molecules at all passed the condition.\n");
4128
 
                mprintf("    This is probably not what you wanted.\n");
4129
 
        } else
4130
 
        {
4131
 
                mprintf(YELLOW,"\nList of reference molecules (%s) that passed the conditions:\n\n",((CMolecule*)g_oaMolecules[m_iRefMol])->m_sName);
4132
 
                for (z=0;z<((CMolecule*)g_oaMolecules[m_iRefMol])->m_laSingleMolIndex.GetSize();z++)
4133
 
                        if (m_iRMPassCounter[z] > 0)
4134
 
                                mprintf("  - %2d: %10.4f percent of the time (%d hits)\n",z+1,((double)m_iRMPassCounter[z])/g_iSteps*100.0,m_iRMPassCounter[z]);
4135
 
 
4136
 
                mprintf(YELLOW,"\nList of observed molecules (%s) that passed the conditions:\n\n",((CMolecule*)g_oaMolecules[m_iShowMol])->m_sName);
4137
 
                for (z=0;z<((CMolecule*)g_oaMolecules[m_iShowMol])->m_laSingleMolIndex.GetSize();z++)
4138
 
                        if (m_iOMPassCounter[z] > 0)
4139
 
                                mprintf("  - %2d: %10.4f percent of the time (%d hits)\n",z+1,((double)m_iOMPassCounter[z])/g_iSteps*100.0,m_iOMPassCounter[z]);
4140
 
        }
4141
 
        mprintf(YELLOW,"\nNeighbor count histogram:\n\n");
4142
 
        for (z=0;z<((CMolecule*)g_oaMolecules[m_iShowMol])->m_laSingleMolIndex.GetSize()+1;z++)
4143
 
                if (m_pHistogram[z] != 0)
4144
 
                        mprintf("  - %d Neighbors: %8.4f percent of the time (%d hits).\n",z,((double)m_pHistogram[z])/m_iHistoGes*100.0,m_pHistogram[z]);
4145
 
        mprintf(YELLOW,"\nListing for all sets of conditions:\n");
4146
 
        for (z=0;z<m_oaConditionSubGroups.GetSize();z++)
4147
 
                ((CConditionSubGroup*)m_oaConditionSubGroups[z])->PrintData();
4148
 
        mprintf(GREEN,"\n<<< End of Condition Data <<<\n\n");
4149
 
}
4150
 
 
4151
 
 
4152
 
void CConditionGroup::PrintData(char *s)
4153
 
{
4154
 
        int z;
4155
 
        FILE *a;
4156
 
 
4157
 
        mprintf(GREEN,"\n>>> Condition Data >>>\n\n");
4158
 
        mprintf("    %.0f of %.0f molecules passed the conditions (%.2f percent).\n",m_fPassed,m_fTotal,ZeroDivide(m_fPassed,m_fTotal)*100.0f);
4159
 
        if (m_fPassed == 0)
4160
 
        {
4161
 
                mprintf("\n    No molecules at all passed the condition.\n");
4162
 
                mprintf("    This is probably not what you wanted.\n");
4163
 
        }
4164
 
        mprintf("\nNeighbor count histogram:\n\n");
4165
 
        for (z=0;z<((CMolecule*)g_oaMolecules[m_iShowMol])->m_laSingleMolIndex.GetSize()+1;z++)
4166
 
                if (m_pHistogram[z] != 0)
4167
 
                        mprintf("  - %d Neighbors: %8.4f percent of the time (%d hits).\n",z,((double)m_pHistogram[z])/m_iHistoGes*100.0,m_pHistogram[z]);
4168
 
        mprintf("\n    Saving detailed condition data as \"%s\"...\n",s);
4169
 
 
4170
 
        a = OpenFileWrite(s,true);
4171
 
 
4172
 
        mfprintf(a,"\n>>> Condition Data >>>\n\n");
4173
 
        mfprintf(a,"    %.0f of %.0f molecules passed the conditions (%.2f percent).\n",m_fPassed,m_fTotal,ZeroDivide(m_fPassed,m_fTotal)*100.0f);
4174
 
        if (m_fPassed == 0)
4175
 
        {
4176
 
                mfprintf(a,"\n    No molecules at all passed the condition.\n");
4177
 
                mfprintf(a,"    This is probably not what you wanted.\n");
4178
 
        } else
4179
 
        {
4180
 
                mfprintf(a,"\nList of reference molecules (%s) that passed the conditions:\n\n",((CMolecule*)g_oaMolecules[m_iRefMol])->m_sName);
4181
 
                for (z=0;z<((CMolecule*)g_oaMolecules[m_iRefMol])->m_laSingleMolIndex.GetSize();z++)
4182
 
                        if (m_iRMPassCounter[z] > 0)
4183
 
                                mfprintf(a,"  - %2d: %10.4f percent of the time (%lu hits)\n",z+1,((double)m_iRMPassCounter[z])/g_iSteps*100.0,m_iRMPassCounter[z]);
4184
 
 
4185
 
                mfprintf(a,"\nList of observed molecules (%s) that passed the conditions:\n\n",((CMolecule*)g_oaMolecules[m_iShowMol])->m_sName);
4186
 
                for (z=0;z<((CMolecule*)g_oaMolecules[m_iShowMol])->m_laSingleMolIndex.GetSize();z++)
4187
 
                        if (m_iOMPassCounter[z] > 0)
4188
 
                                mfprintf(a,"  - %2d: %10.4f percent of the time (%lu hits)\n",z+1,((double)m_iOMPassCounter[z])/g_iSteps*100.0,m_iOMPassCounter[z]);
4189
 
        }
4190
 
        mfprintf(a,"\nNeighbor count histogram:\n\n");
4191
 
        for (z=0;z<((CMolecule*)g_oaMolecules[m_iShowMol])->m_laSingleMolIndex.GetSize()+1;z++)
4192
 
                if (m_pHistogram[z] != 0)
4193
 
                        mfprintf(a,"  - %d Neighbors: %8.4f percent of the time (%lu hits).\n",z,((double)m_pHistogram[z])/m_iHistoGes*100.0,m_pHistogram[z]);
4194
 
        mfprintf(a,"\nListing for all sets of conditions:\n");
4195
 
        for (z=0;z<m_oaConditionSubGroups.GetSize();z++)
4196
 
                ((CConditionSubGroup*)m_oaConditionSubGroups[z])->PrintData(a);
4197
 
        mfprintf(a,"\n<<< End of Condition Data <<<\n\n");
4198
 
 
4199
 
        fclose(a);
4200
 
        mprintf(GREEN,"\n<<< End of Condition Data <<<\n\n");
4201
 
}
4202
 
 
4203
 
 
4204
 
bool CConditionSubGroup::Contains(int mol)
4205
 
{
4206
 
        BXIN;
4207
 
        int z;
4208
 
 
4209
 
        for (z=0;z<m_oaConditions.GetSize();z++)
4210
 
        {
4211
 
                if (!((CNbSearch*)m_oaConditions[z])->m_bPassed[mol])
4212
 
                {
4213
 
                        BXOUT;
4214
 
                        return false;
4215
 
                }
4216
 
        }
4217
 
        BXOUT;
4218
 
        return true;
4219
 
}
4220
 
 
4221
 
 
4222
 
void CConditionSubGroup::MarkPassedAtoms(int om)
4223
 
{
4224
 
        int z, z2;
4225
 
 
4226
 
        for (z=0;z<g_iGesVirtAtomCount;z++)
4227
 
                m_bTempPassed[z] = false;
4228
 
 
4229
 
        for (z=0;z<m_oaConditions.GetSize();z++)
4230
 
        {
4231
 
                for (z2=0;z2<g_iGesVirtAtomCount;z2++)
4232
 
                        if (g_baAtomPassedCondition[z2] < 100)
4233
 
                                g_baAtomPassedCondition[z2] = 0;
4234
 
 
4235
 
                ((CNbSearch*)m_oaConditions[z])->MarkPassedAtoms(om);
4236
 
 
4237
 
                for (z2=0;z2<g_iGesVirtAtomCount;z2++)
4238
 
                        if (g_baAtomPassedCondition[z2] == 1)
4239
 
                                m_bTempPassed[z2] = true;
4240
 
        }
4241
 
 
4242
 
        for (z=0;z<g_iGesVirtAtomCount;z++)
4243
 
                if (m_bTempPassed[z])
4244
 
                        g_baAtomPassedCondition[z] = 100;
4245
 
}
4246
 
 
4247
 
 
4248
 
void CConditionSubGroup::ScanNeighborhoodAllOM(CTimeStep *t, CSingleMolecule *rm)
4249
 
{
4250
 
        int z, z2;
4251
 
 
4252
 
        for (z=0;z<m_oaConditions.GetSize();z++)
4253
 
                ((CNbSearch*)m_oaConditions[z])->ScanAllOM(rm,t);
4254
 
 
4255
 
        for (z=0;z<((CMolecule*)g_oaMolecules[m_iShowMol])->m_laSingleMolIndex.GetSize();z++)
4256
 
        {
4257
 
                m_fTotal++;
4258
 
                for (z2=0;z2<m_oaConditions.GetSize();z2++)
4259
 
                        if (!((CNbSearch*)m_oaConditions[z2])->m_bPassed[z])
4260
 
                                goto _nopass;
4261
 
                m_fPassed++;
4262
 
_nopass:;
4263
 
        }
4264
 
}
4265
 
 
4266
 
 
4267
 
void CConditionSubGroup::PreScanNeighborhoodAllOM(CTimeStep *t, CSingleMolecule *rm)
4268
 
{
4269
 
        int z;
4270
 
 
4271
 
        for (z=0;z<m_oaConditions.GetSize();z++)
4272
 
                ((CNbSearch*)m_oaConditions[z])->PreScanAllOM(rm,t);
4273
 
}
4274
 
 
4275
 
 
4276
 
void CConditionSubGroup::Parse(int rm, int sm)
4277
 
{
4278
 
        BTIN;
4279
 
        CNbSearch *n;
4280
 
 
4281
 
        m_iCombinations = 0;
4282
 
        do
4283
 
        {
4284
 
                try { n = new CNbSearch(); } catch(...) { n = NULL; }
4285
 
                if (n == NULL) NewException((double)sizeof(CNbSearch),__FILE__,__LINE__,__PRETTY_FUNCTION__);
4286
 
                
4287
 
                n->m_iNumber = m_oaConditions.GetSize();
4288
 
                m_oaConditions.Add(n);
4289
 
                n->Parse(rm,sm,false);
4290
 
                m_iCombinations += n->m_iCombinationsEnabled;
4291
 
        } while (AskYesNo("    Add another condition to this set of conditions (y/n)? [no] ",false));
4292
 
 
4293
 
        try { m_bTempPassed = new bool[g_iGesVirtAtomCount]; } catch(...) { m_bTempPassed = NULL; }
4294
 
        if (m_bTempPassed == NULL) NewException((double)g_iGesVirtAtomCount*sizeof(bool),__FILE__,__LINE__,__PRETTY_FUNCTION__);
4295
 
        
4296
 
        BTOUT;
4297
 
}
4298
 
 
4299
 
 
4300
 
void CADF::ParseCondition(int rm, bool nocrit)
4301
 
{
4302
 
        BTIN;
4303
 
        char buf[256];
4304
 
        int z, z2, ti;
4305
 
        CAtomGroup *ag;
4306
 
 
4307
 
        mprintf(WHITE,"\n>>> Angular Condition >>>\n");
4308
 
        for (z=0;z<2;z++)
4309
 
                m_iVecType[z] = 0;
4310
 
        z2 = 0;
4311
 
        m_iCombinations = 0;
4312
 
        do {
4313
 
                ti = 1;
4314
 
                if (z2 != 0)
4315
 
                        mprintf("\n    %d. set of vectors\n\n",z2+1);
4316
 
                for (z=0;z<2;z++)
4317
 
                {
4318
 
/*                      if (z == 1)
4319
 
                                m_bSameFoot = AskYesNo("    Should the base points of the 1st and 2nd vectors always be equal (y/n)? [no] ",false);
4320
 
                                        else m_bSameFoot = false;*/
4321
 
                        m_bOrtho[z] = (AskRangeInteger("\n    Should the %d. vector connect two points (0) or stand perpendicular on 3 points (1)? [0] ",0,1,0,z+1) != 0);
4322
 
                        mprintf("\n");
4323
 
                        if (m_bOrtho[z])
4324
 
                        {
4325
 
/*                              if (m_bSameFoot && (z == 1))
4326
 
                                {
4327
 
                                        m_iRefOrSec[1][0] = m_iRefOrSec[0][0];
4328
 
                                        m_oaVectors.Add(NULL);
4329
 
                                } else*/
4330
 
                                {
4331
 
_ax1:                           if (m_iShowMol != -1)
4332
 
                                                m_iRefOrSec[z][0] = AskRangeInteger("    Take atom(s) in base point from 1st mol. %s (0) or from 2nd mol. %s (1)? [%d] ",0,1,z,((CMolecule*)g_oaMolecules[rm])->m_sName,((CMolecule*)g_oaMolecules[m_iShowMol])->m_sName,z);
4333
 
                                                        else m_iRefOrSec[z][0] = 0;
4334
 
                                        mprintf("      Enter atom(s) in the base point (e.g. C7): ");
4335
 
                                        inpprintf("! Enter atom(s) in the base point (e.g. C7):\n");
4336
 
                                        myget(buf);
4337
 
 
4338
 
                                        try { ag = new CAtomGroup(); } catch(...) { ag = NULL; }
4339
 
                                        if (ag == NULL) NewException((double)sizeof(CAtomGroup),__FILE__,__LINE__,__PRETTY_FUNCTION__);
4340
 
 
4341
 
                                        if (!ag->ParseAtoms((!m_iRefOrSec[z][0])?(CMolecule*)g_oaMolecules[rm]:(CMolecule*)g_oaMolecules[m_iShowMol],buf))
4342
 
                                        {
4343
 
                                                eprintf("Wrong input.\n");
4344
 
                                                inpprintf("! Wrong input.\n");
4345
 
                                                delete ag;
4346
 
                                                goto _ax1;
4347
 
                                        }
4348
 
                                        m_oaVectors.Add(ag);
4349
 
                                        ti *= ag->m_iAtomGes;
4350
 
                                }
4351
 
_ax2:                   if (m_iShowMol != -1)
4352
 
                                        m_iRefOrSec[z][1] = AskRangeInteger("   Take 2nd atom(s) of normal plane from 1st mol. %s (0) or from 2nd mol. %s (1)? [%d] ",0,1,z,((CMolecule*)g_oaMolecules[rm])->m_sName,((CMolecule*)g_oaMolecules[m_iShowMol])->m_sName,z);
4353
 
                                                else m_iRefOrSec[z][1] = 0;
4354
 
                                mprintf("      Enter 2nd atom(s) of normal plane (e.g. C7): ");
4355
 
                                inpprintf("! Enter 2nd atom(s) of normal plane (e.g. C7):\n");
4356
 
                                myget(buf);
4357
 
 
4358
 
                                try { ag = new CAtomGroup(); } catch(...) { ag = NULL; }
4359
 
                                if (ag == NULL) NewException((double)sizeof(CAtomGroup),__FILE__,__LINE__,__PRETTY_FUNCTION__);
4360
 
 
4361
 
                                if (!ag->ParseAtoms((!m_iRefOrSec[z][1])?(CMolecule*)g_oaMolecules[rm]:(CMolecule*)g_oaMolecules[m_iShowMol],buf))
4362
 
                                {
4363
 
                                        eprintf("Wrong input.\n");
4364
 
                                        inpprintf("! Wrong input.\n");
4365
 
                                        delete ag;
4366
 
                                        goto _ax2;
4367
 
                                }
4368
 
                                m_oaVectors.Add(ag);
4369
 
                                ti *= ag->m_iAtomGes;
4370
 
_ax3:                   if (m_iShowMol != -1)
4371
 
                                        m_iRefOrSec[z][2] = AskRangeInteger("    Take 3rd atom(s) of normal plane from 1st mol. %s (0) or from 2nd mol. %s (1)? [%d] ",0,1,z,((CMolecule*)g_oaMolecules[rm])->m_sName,((CMolecule*)g_oaMolecules[m_iShowMol])->m_sName,z);
4372
 
                                                else m_iRefOrSec[z][2] = 0;
4373
 
                                mprintf("      Enter 3rd atom(s) of normal plane (e.g. C7): ");
4374
 
                                inpprintf("! Enter 3rd atom(s) of normal plane (e.g. C7):\n");
4375
 
                                myget(buf);
4376
 
 
4377
 
                                try { ag = new CAtomGroup(); } catch(...) { ag = NULL; }
4378
 
                                if (ag == NULL) NewException((double)sizeof(CAtomGroup),__FILE__,__LINE__,__PRETTY_FUNCTION__);
4379
 
 
4380
 
                                if (!ag->ParseAtoms((!m_iRefOrSec[z][2])?(CMolecule*)g_oaMolecules[rm]:(CMolecule*)g_oaMolecules[m_iShowMol],buf))
4381
 
                                {
4382
 
                                        eprintf("Wrong input.\n");
4383
 
                                        inpprintf("! Wrong input.\n");
4384
 
                                        delete ag;
4385
 
                                        goto _ax3;
4386
 
                                }
4387
 
                                m_oaVectors.Add(ag);
4388
 
                                ti *= ag->m_iAtomGes;
4389
 
                        } else // IF NOT ORTHO
4390
 
                        {
4391
 
/*                              if (m_bSameFoot && (z == 1))
4392
 
                                {
4393
 
                                        m_iRefOrSec[1][0] = m_iRefOrSec[0][0];
4394
 
                                        m_oaVectors.Add(NULL);
4395
 
                                } else*/
4396
 
                                {
4397
 
_ax4:                           if (m_iShowMol != -1)
4398
 
                                                m_iRefOrSec[z][0] = AskRangeInteger("    Take atom(s) in base point from 1st mol. %s (0) or from 2nd mol. %s (1)? [%d] ",0,1,z,((CMolecule*)g_oaMolecules[rm])->m_sName,((CMolecule*)g_oaMolecules[m_iShowMol])->m_sName,z);
4399
 
                                                        else m_iRefOrSec[z][0] = 0;
4400
 
                                        mprintf("      Enter atom(s) in the base point (e.g. C7): ");
4401
 
                                        inpprintf("! Enter atom(s) in the base point (e.g. C7):\n");
4402
 
                                        myget(buf);
4403
 
 
4404
 
                                        try { ag = new CAtomGroup(); } catch(...) { ag = NULL; }
4405
 
                                        if (ag == NULL) NewException((double)sizeof(CAtomGroup),__FILE__,__LINE__,__PRETTY_FUNCTION__);
4406
 
 
4407
 
                                        if (!ag->ParseAtoms((!m_iRefOrSec[z][0])?(CMolecule*)g_oaMolecules[rm]:(CMolecule*)g_oaMolecules[m_iShowMol],buf))
4408
 
                                        {
4409
 
                                                eprintf("Wrong input.\n");
4410
 
                                                inpprintf("! Wrong input.\n");
4411
 
                                                delete ag;
4412
 
                                                goto _ax4;
4413
 
                                        }
4414
 
                                        m_oaVectors.Add(ag);
4415
 
                                        ti *= ag->m_iAtomGes;
4416
 
                                } // END IF NOT SAMEFOOT
4417
 
_ax5:                   if (m_iShowMol != -1)
4418
 
                                        m_iRefOrSec[z][1] = AskRangeInteger("    Take atom(s) in tip point from 1st mol. %s (0) or from 2nd mol. %s (1)? [%d] ",0,1,z,((CMolecule*)g_oaMolecules[rm])->m_sName,((CMolecule*)g_oaMolecules[m_iShowMol])->m_sName,z);
4419
 
                                                else m_iRefOrSec[z][1] = 0;
4420
 
                                mprintf("      Enter atom(s) in the tip point (e.g. C7): ");
4421
 
                                inpprintf("! Enter atom(s) in the tip point (e.g. C7):\n");
4422
 
                                myget(buf);
4423
 
 
4424
 
                                try { ag = new CAtomGroup(); } catch(...) { ag = NULL; }
4425
 
                                if (ag == NULL) NewException((double)sizeof(CAtomGroup),__FILE__,__LINE__,__PRETTY_FUNCTION__);
4426
 
 
4427
 
                                if (!ag->ParseAtoms((!m_iRefOrSec[z][1])?(CMolecule*)g_oaMolecules[rm]:(CMolecule*)g_oaMolecules[m_iShowMol],buf))
4428
 
                                {
4429
 
                                        eprintf("Wrong input.\n");
4430
 
                                        inpprintf("! Wrong input.\n");
4431
 
                                        delete ag;
4432
 
                                        goto _ax5;
4433
 
                                }
4434
 
                                m_oaVectors.Add(ag);
4435
 
                                ti *= ag->m_iAtomGes;
4436
 
                                m_oaVectors.Add(NULL);
4437
 
                        } // END IF NOT ORTHO
4438
 
                } // END FOR 0..1
4439
 
                m_iCombinations += ti;
4440
 
                z2++;
4441
 
        } while (AskYesNo("\n    Enter another set of vectors (y/n)? [no] ",false));
4442
 
        if (!nocrit)
4443
 
        {
4444
 
                do {
4445
 
                        m_faMinMaxAngle.Add(AskFloat("    Enter minimal angle between the vectors in degree: [0.0] ",0.0f));
4446
 
                        m_faMinMaxAngle.Add(AskFloat("    Enter maximal angle between the vectors in degree: [180.0] ",180.0f));
4447
 
                } while (AskYesNo("    Enter another angle interval (y/n)? [no] ",false));
4448
 
        } else
4449
 
        {
4450
 
                m_faMinMaxAngle.Add(0.0f);
4451
 
                m_faMinMaxAngle.Add(180.0f);
4452
 
        }
4453
 
        mprintf(WHITE,"\n<<< End of Angular Condition <<<\n\n");
4454
 
        BTOUT;
4455
 
}
4456
 
 
4457
 
 
4458
 
void CADF::ParseConditionGrid(int rm, int gridmode)
4459
 
{
4460
 
        BTIN;
4461
 
        char buf[256];
4462
 
        int z, z2, ti;
4463
 
        CAtomGroup *ag;
4464
 
 
4465
 
        mprintf(WHITE,"\n>>> Angular Condition >>>\n");
4466
 
        for (z=0;z<2;z++)
4467
 
                m_iVecType[z] = 0;
4468
 
        z2 = 0;
4469
 
        m_iCombinations = 0;
4470
 
        do {
4471
 
                ti = 1;
4472
 
                if (z2 != 0)
4473
 
                        mprintf("\n    %d. set of vectors\n\n",z2+1);
4474
 
                for (z=0;z<2;z++)
4475
 
                {
4476
 
/*                      if (z == 1)
4477
 
                                m_bSameFoot = AskYesNo("    Should the base points of the 1st and 2nd vectors always be equal (y/n)? [no] ",false);
4478
 
                                        else m_bSameFoot = false;*/
4479
 
                        m_bOrtho[z] = (AskRangeInteger("\n    Should the %d. vector connect two points (0) or stand perpendicular on 3 points (1)? [0] ",0,1,0,z+1) != 0);
4480
 
                        mprintf("\n");
4481
 
                        if (m_bOrtho[z])
4482
 
                        {
4483
 
/*                              if (m_bSameFoot && (z == 1))
4484
 
                                {
4485
 
                                        m_iRefOrSec[1][0] = m_iRefOrSec[0][0];
4486
 
                                        m_oaVectors.Add(NULL);
4487
 
                                } else*/
4488
 
                                {
4489
 
_ax1:                           if (m_iShowMol != -1)
4490
 
                                                m_iRefOrSec[z][0] = AskRangeInteger("    Take atom(s) in base point from 1st mol. %s (0) or from 2nd mol. %s (1)? [%d] ",0,1,z,((CMolecule*)g_oaMolecules[rm])->m_sName,((CMolecule*)g_oaMolecules[m_iShowMol])->m_sName,z);
4491
 
                                                        else m_iRefOrSec[z][0] = 0;
4492
 
                                        mprintf("      Enter atom(s) in the base point (e.g. C7): ");
4493
 
                                        inpprintf("! Enter atom(s) in the base point (e.g. C7):\n");
4494
 
                                        myget(buf);
4495
 
 
4496
 
                                        try { ag = new CAtomGroup(); } catch(...) { ag = NULL; }
4497
 
                                        if (ag == NULL) NewException((double)sizeof(CAtomGroup),__FILE__,__LINE__,__PRETTY_FUNCTION__);
4498
 
 
4499
 
                                        m_oaVectors.Add(ag);
4500
 
                                        if (!ag->ParseAtoms((!m_iRefOrSec[z][0])?(CMolecule*)g_oaMolecules[rm]:(CMolecule*)g_oaMolecules[m_iShowMol],buf))
4501
 
                                        {
4502
 
                                                eprintf("Wrong input.\n");
4503
 
                                                inpprintf("! Wrong input.\n");
4504
 
                                                goto _ax1;
4505
 
                                        }
4506
 
                                        ti *= ag->m_iAtomGes;
4507
 
                                }
4508
 
_ax2:                   if (m_iShowMol != -1)
4509
 
                                        m_iRefOrSec[z][1] = AskRangeInteger("   Take 2nd atom(s) of normal plane from 1st mol. %s (0) or from 2nd mol. %s (1)? [%d] ",0,1,z,((CMolecule*)g_oaMolecules[rm])->m_sName,((CMolecule*)g_oaMolecules[m_iShowMol])->m_sName,z);
4510
 
                                                else m_iRefOrSec[z][1] = 0;
4511
 
                                mprintf("      Enter 2nd atom(s) of normal plane (e.g. C7): ");
4512
 
                                inpprintf("! Enter 2nd atom(s) of normal plane (e.g. C7):\n");
4513
 
                                myget(buf);
4514
 
 
4515
 
                                try { ag = new CAtomGroup(); } catch(...) { ag = NULL; }
4516
 
                                if (ag == NULL) NewException((double)sizeof(CAtomGroup),__FILE__,__LINE__,__PRETTY_FUNCTION__);
4517
 
 
4518
 
                                m_oaVectors.Add(ag);
4519
 
                                if (!ag->ParseAtoms((!m_iRefOrSec[z][1])?(CMolecule*)g_oaMolecules[rm]:(CMolecule*)g_oaMolecules[m_iShowMol],buf))
4520
 
                                {
4521
 
                                        eprintf("Wrong input.\n");
4522
 
                                        inpprintf("! Wrong input.\n");
4523
 
                                        goto _ax2;
4524
 
                                }
4525
 
                                ti *= ag->m_iAtomGes;
4526
 
_ax3:                   if (m_iShowMol != -1)
4527
 
                                        m_iRefOrSec[z][2] = AskRangeInteger("    Take 3rd atom(s) of normal plane from 1st mol. %s (0) or from 2nd mol. %s (1)? [%d] ",0,1,z,((CMolecule*)g_oaMolecules[rm])->m_sName,((CMolecule*)g_oaMolecules[m_iShowMol])->m_sName,z);
4528
 
                                                else m_iRefOrSec[z][2] = 0;
4529
 
                                mprintf("      Enter 3rd atom(s) of normal plane (e.g. C7): ");
4530
 
                                inpprintf("! Enter 3rd atom(s) of normal plane (e.g. C7):\n");
4531
 
                                myget(buf);
4532
 
 
4533
 
                                try { ag = new CAtomGroup(); } catch(...) { ag = NULL; }
4534
 
                                if (ag == NULL) NewException((double)sizeof(CAtomGroup),__FILE__,__LINE__,__PRETTY_FUNCTION__);
4535
 
 
4536
 
                                m_oaVectors.Add(ag);
4537
 
                                if (!ag->ParseAtoms((!m_iRefOrSec[z][2])?(CMolecule*)g_oaMolecules[rm]:(CMolecule*)g_oaMolecules[m_iShowMol],buf))
4538
 
                                {
4539
 
                                        eprintf("Wrong input.\n");
4540
 
                                        inpprintf("! Wrong input.\n");
4541
 
                                        goto _ax3;
4542
 
                                }
4543
 
                                ti *= ag->m_iAtomGes;
4544
 
                        } else // IF NOT ORTHO
4545
 
                        {
4546
 
/*                              if (m_bSameFoot && (z == 1))
4547
 
                                {
4548
 
                                        m_iRefOrSec[1][0] = m_iRefOrSec[0][0];
4549
 
                                        m_oaVectors.Add(NULL);
4550
 
                                } else*/
4551
 
                                {
4552
 
_ax4:                           if (m_iShowMol != -1)
4553
 
                                                m_iRefOrSec[z][0] = AskRangeInteger("    Take atom(s) in base point from 1st mol. %s (0) or from 2nd mol. %s (1)? [%d] ",0,1,z,((CMolecule*)g_oaMolecules[rm])->m_sName,((CMolecule*)g_oaMolecules[m_iShowMol])->m_sName,z);
4554
 
                                                        else m_iRefOrSec[z][0] = 0;
4555
 
                                        mprintf("      Enter atom(s) in the base point (e.g. C7): ");
4556
 
                                        inpprintf("! Enter atom(s) in the base point (e.g. C7):\n");
4557
 
                                        myget(buf);
4558
 
 
4559
 
                                        try { ag = new CAtomGroup(); } catch(...) { ag = NULL; }
4560
 
                                        if (ag == NULL) NewException((double)sizeof(CAtomGroup),__FILE__,__LINE__,__PRETTY_FUNCTION__);
4561
 
 
4562
 
                                        m_oaVectors.Add(ag);
4563
 
                                        if (!ag->ParseAtoms((!m_iRefOrSec[z][0])?(CMolecule*)g_oaMolecules[rm]:(CMolecule*)g_oaMolecules[m_iShowMol],buf))
4564
 
                                        {
4565
 
                                                eprintf("Wrong input.\n");
4566
 
                                                inpprintf("! Wrong input.\n");
4567
 
                                                goto _ax4;
4568
 
                                        }
4569
 
                                        ti *= ag->m_iAtomGes;
4570
 
                                } // END IF NOT SAMEFOOT
4571
 
_ax5:                   if (m_iShowMol != -1)
4572
 
                                        m_iRefOrSec[z][1] = AskRangeInteger("    Take atom(s) in tip point from 1st mol. %s (0) or from 2nd mol. %s (1)? [%d] ",0,1,z,((CMolecule*)g_oaMolecules[rm])->m_sName,((CMolecule*)g_oaMolecules[m_iShowMol])->m_sName,z);
4573
 
                                                else m_iRefOrSec[z][1] = 0;
4574
 
                                mprintf("      Enter atom(s) in the tip point (e.g. C7): ");
4575
 
                                inpprintf("! Enter atom(s) in the tip point (e.g. C7):\n");
4576
 
                                myget(buf);
4577
 
 
4578
 
                                try { ag = new CAtomGroup(); } catch(...) { ag = NULL; }
4579
 
                                if (ag == NULL) NewException((double)sizeof(CAtomGroup),__FILE__,__LINE__,__PRETTY_FUNCTION__);
4580
 
 
4581
 
                                m_oaVectors.Add(ag);
4582
 
                                if (!ag->ParseAtoms((!m_iRefOrSec[z][1])?(CMolecule*)g_oaMolecules[rm]:(CMolecule*)g_oaMolecules[m_iShowMol],buf))
4583
 
                                {
4584
 
                                        eprintf("Wrong input.\n");
4585
 
                                        inpprintf("! Wrong input.\n");
4586
 
                                        goto _ax5;
4587
 
                                }
4588
 
                                ti *= ag->m_iAtomGes;
4589
 
                                m_oaVectors.Add(NULL);
4590
 
                        } // END IF NOT ORTHO
4591
 
                } // END FOR 0..1
4592
 
                m_iCombinations += ti;
4593
 
                z2++;
4594
 
        } while (AskYesNo("\n    Enter another set of vectors (y/n)? [no] ",false));
4595
 
        if ((gridmode == 1) || (gridmode == 6))
4596
 
        {
4597
 
                m_faMinMaxAngle.Add(AskFloat("    Enter minimal angle between the vectors in degree: [0.0] ",0.0f));
4598
 
                m_faMinMaxAngle.Add(AskFloat("    Enter maximal angle between the vectors in degree: [180.0] ",180.0f));
4599
 
        } else
4600
 
        {
4601
 
                m_faMinMaxAngle.Add(0.0f);
4602
 
                m_faMinMaxAngle.Add(180.0f);
4603
 
        }
4604
 
        mprintf(WHITE,"\n<<< End of Angular Condition <<<\n\n");
4605
 
        BTOUT;
4606
 
}
4607
 
 
4608
 
 
4609
 
void CADF::ParseCondition_OnlyValues()
4610
 
{
4611
 
        BTIN;
4612
 
        int z;
4613
 
 
4614
 
        mprintf("    Angular condition between vectors:\n");
4615
 
        for (z=0;z<m_oaVectors.GetSize()/6;z++)
4616
 
        {
4617
 
                mprintf("      ");
4618
 
                if (m_oaVectors[z*6+2] != NULL)
4619
 
                        mprintf("normal(%s, %s, %s)",((CAtomGroup*)m_oaVectors[z*6])->m_sName,((CAtomGroup*)m_oaVectors[z*6+1])->m_sName,((CAtomGroup*)m_oaVectors[z*6+2])->m_sName);
4620
 
                                else mprintf("(%s --> %s)",((CAtomGroup*)m_oaVectors[z*6])->m_sName,((CAtomGroup*)m_oaVectors[z*6+1])->m_sName);
4621
 
                mprintf(" and ");
4622
 
                if (m_oaVectors[z*6+5] != NULL)
4623
 
                        mprintf("normal(%s, %s, %s)",((CAtomGroup*)m_oaVectors[z*6+3])->m_sName,((CAtomGroup*)m_oaVectors[z*6+4])->m_sName,((CAtomGroup*)m_oaVectors[z*6+5])->m_sName);
4624
 
                                else mprintf("(%s --> %s)",((CAtomGroup*)m_oaVectors[z*6+3])->m_sName,((CAtomGroup*)m_oaVectors[z*6+4])->m_sName);
4625
 
                mprintf("\n");
4626
 
        }
4627
 
        for (z=0;z<m_faMinMaxAngle.GetSize()/2;z++)
4628
 
        {
4629
 
                mprintf("    Interval %d:\n",z+1,m_faMinMaxAngle.GetSize()/2);
4630
 
                m_faMinMaxAngle[z*2] = AskFloat("      Enter minimal angle between the vectors in degree: [0.0] ",0.0f);
4631
 
                m_faMinMaxAngle[z*2+1] = AskFloat("      Enter maximal angle between the vectors in degree: [180.0] ",180.0f);
4632
 
        } 
4633
 
//      mprintf(WHITE,"\n<<< End of Angular Condition <<<\n\n");
4634
 
        BTOUT;
4635
 
}
4636
 
 
4637
 
 
4638
 
CObservation::CObservation()
4639
 
{
4640
 
        m_pConditions = NULL;
4641
 
        m_pConditionsOM2 = NULL;
4642
 
        m_pMSD = NULL;
4643
 
        m_pSDF = NULL;
4644
 
        m_pCDF = NULL;
4645
 
        m_pVACF = NULL;
4646
 
        m_pDipACF = NULL;
4647
 
        m_pADF = NULL;
4648
 
        m_pDDF = NULL;
4649
 
        m_pRDF = NULL;
4650
 
        m_pDipDF = NULL;
 
3630
 
 
3631
        if (g_bAdvanced2)
 
3632
                m_iHistogramRes = AskUnsignedInteger("    Please enter histogram resolution (0=no histogram): [5000] ",5000);
 
3633
                        else m_iHistogramRes = 0;
 
3634
 
 
3635
/*      mprintf("    Save temporal Development of Velocity (0=no, 1=yes)? [0] ");
 
3636
        myget(buf);
 
3637
        m_bSaveSpeed = atoi(buf)!=0;*/
 
3638
        BuildName();
 
3639
        mprintf(WHITE,"\n<<< End of Velocity Distribution Function <<<\n\n");
 
3640
        BTOUT;
 
3641
}
 
3642
 
 
3643
 
 
3644
void CSDF::BuildName()
 
3645
{
 
3646
        BTIN;
 
3647
        char tmp[256];
 
3648
 
 
3649
        tmp[0] = 0;
 
3650
 
 
3651
        if (m_iRefOrSec)
 
3652
                sprintf(tmp,"%s_%s%d%s%d%s%d_%s_%s",((CMolecule*)g_oaMolecules[g_iFixMol])->m_sName,((CAtom*)g_oaAtoms[g_iFixRealAtomType[0]])->m_sName,g_iFixAtom[0]+1,((CAtom*)g_oaAtoms[g_iFixRealAtomType[1]])->m_sName,g_iFixAtom[1]+1,((CAtom*)g_oaAtoms[g_iFixRealAtomType[2]])->m_sName,g_iFixAtom[2]+1,((CMolecule*)g_oaMolecules[m_iShowMol])->m_sName,m_oAtoms.m_sName);
 
3653
                        else sprintf(tmp,"%s_%s%d%s%d%s%d_%s",((CMolecule*)g_oaMolecules[g_iFixMol])->m_sName,((CAtom*)g_oaAtoms[g_iFixRealAtomType[0]])->m_sName,g_iFixAtom[0]+1,((CAtom*)g_oaAtoms[g_iFixRealAtomType[1]])->m_sName,g_iFixAtom[1]+1,((CAtom*)g_oaAtoms[g_iFixRealAtomType[2]])->m_sName,g_iFixAtom[2]+1,m_oAtoms.m_sName);
 
3654
 
 
3655
        try { m_sName = new char[strlen(tmp)+1]; } catch(...) { m_sName = NULL; }
 
3656
        if (m_sName == NULL) NewException((double)(strlen(tmp)+1)*sizeof(char),__FILE__,__LINE__,__PRETTY_FUNCTION__);
 
3657
        
 
3658
        strcpy(m_sName,tmp);
 
3659
        BTOUT;
 
3660
}
 
3661
 
 
3662
 
 
3663
void CVDF::BuildName()
 
3664
{
 
3665
        BTIN;
 
3666
        char tmp[256];
 
3667
 
 
3668
        if (m_iDeriv != 0)
 
3669
                sprintf(tmp,"deriv%d_%s",m_iDeriv,m_oAtoms.m_sName);
 
3670
                        else sprintf(tmp,"%s",m_oAtoms.m_sName);
 
3671
 
 
3672
        try { m_sShortName = new char[strlen(tmp)+1]; } catch(...) { m_sShortName = NULL; }
 
3673
        if (m_sShortName == NULL) NewException((double)(strlen(tmp)+1)*sizeof(char),__FILE__,__LINE__,__PRETTY_FUNCTION__);
 
3674
        
 
3675
        strcpy(m_sShortName,m_oAtoms.m_sName);
 
3676
        if (g_iFixMol == -1)
 
3677
        {
 
3678
                sprintf(tmp,"%s_",((CMolecule*)g_oaMolecules[m_iShowMol])->m_sName);
 
3679
        } else if (m_iRefOrSec)
 
3680
                sprintf(tmp,"%s_%s%d_%s_",((CMolecule*)g_oaMolecules[g_iFixMol])->m_sName,((CAtom*)g_oaAtoms[g_iFixRealAtomType[0]])->m_sName,g_iFixAtom[0]+1,((CMolecule*)g_oaMolecules[m_iShowMol])->m_sName);
 
3681
                        else sprintf(tmp,"%s_%s%d_",((CMolecule*)g_oaMolecules[g_iFixMol])->m_sName,((CAtom*)g_oaAtoms[g_iFixRealAtomType[0]])->m_sName,g_iFixAtom[0]+1);
 
3682
        strcat(tmp,m_sShortName);
 
3683
 
 
3684
        try { m_sName = new char[strlen(tmp)+1]; } catch(...) { m_sName = NULL; }
 
3685
        if (m_sName == NULL) NewException((double)(strlen(tmp)+1)*sizeof(char),__FILE__,__LINE__,__PRETTY_FUNCTION__);
 
3686
        
 
3687
        strcpy(m_sName,tmp);
 
3688
        BTOUT;
 
3689
}
 
3690
 
 
3691
 
 
3692
void CSDF::BuildAtomList(CSingleMolecule *ref, CSingleMolecule *obs, CxIntArray *vec)
 
3693
{
 
3694
        BXIN;
 
3695
        int z1t, z1a;
 
3696
        CxIntArray *a1;
 
3697
 
 
3698
        vec->RemoveAll_KeepSize();
 
3699
        for (z1t=0;z1t<m_oAtoms.m_baAtomType.GetSize();z1t++)
 
3700
        {
 
3701
//              mprintf("(a) BuildAtomList z1t=%d, WA=%X\n",z1t,m_oAtoms.m_oaAtoms[z1t]);
 
3702
                a1 = (CxIntArray*)m_oAtoms.m_oaAtoms[z1t];
 
3703
//              mprintf("(b) BuildAtomList wa.GetSize()=%d\n",a1->GetSize());
 
3704
                for (z1a=0;z1a<a1->GetSize();z1a++)
 
3705
                        if (m_iRefOrSec)
 
3706
                        {
 
3707
//                              mprintf("(c) BuildAtomList z1t=%d, z1a=%d, Type=%d, WA=%X\n",z1t,z1a,m_oAtoms.m_baAtomType[z1t],obs->m_oaAtomOffset[m_oAtoms.m_baAtomType[z1t]]);
 
3708
                                vec->Add(((CxIntArray*)obs->m_oaAtomOffset[m_oAtoms.m_baAtomType[z1t]])->GetAt(a1->GetAt(z1a)));
 
3709
                        } else vec->Add(((CxIntArray*)ref->m_oaAtomOffset[m_oAtoms.m_baAtomType[z1t]])->GetAt(a1->GetAt(z1a)));
 
3710
        }
 
3711
        BXOUT;
 
3712
}
 
3713
 
 
3714
 
 
3715
void CVDF::BuildAtomList(CSingleMolecule *ref, CSingleMolecule *obs, CxIntArray *vec)
 
3716
{
 
3717
        BXIN;
 
3718
        int z1t, z1a;
 
3719
        CxIntArray *a1;
 
3720
 
 
3721
        vec->RemoveAll_KeepSize();
 
3722
        for (z1t=0;z1t<m_oAtoms.m_baAtomType.GetSize();z1t++)
 
3723
        {
 
3724
                a1 = (CxIntArray*)m_oAtoms.m_oaAtoms[z1t];
 
3725
                for (z1a=0;z1a<a1->GetSize();z1a++)
 
3726
                        if (m_iRefOrSec)
 
3727
                                vec->Add(((CxIntArray*)obs->m_oaAtomOffset[m_oAtoms.m_baAtomType[z1t]])->GetAt(a1->GetAt(z1a)));
 
3728
                                        else vec->Add(((CxIntArray*)ref->m_oaAtomOffset[m_oAtoms.m_baAtomType[z1t]])->GetAt(a1->GetAt(z1a)));
 
3729
        }
 
3730
        BXOUT;
 
3731
}
 
3732
 
 
3733
 
 
3734
void CRDF::BuildAtomList(CSingleMolecule *ref, CSingleMolecule *obs, CxIntArray *vec)
 
3735
{
 
3736
        BXIN;
 
3737
        int z, z1t, z1a, z2t, z2a;
 
3738
        CAtomGroup *g1, *g2;
 
3739
        CxIntArray *a1, *a2;
 
3740
 
 
3741
        vec->RemoveAll_KeepSize();
 
3742
        for (z=0;z<m_oaVectors.GetSize()/2;z++)
 
3743
        {
 
3744
                g1 = (CAtomGroup*)m_oaVectors[z*2];
 
3745
                for (z1t=0;z1t<g1->m_baAtomType.GetSize();z1t++)
 
3746
                {
 
3747
                        a1 = (CxIntArray*)g1->m_oaAtoms[z1t];
 
3748
                        for (z1a=0;z1a<a1->GetSize();z1a++)
 
3749
                        {
 
3750
                                g2 = (CAtomGroup*)m_oaVectors[z*2+1];
 
3751
                                for (z2t=0;z2t<g2->m_baAtomType.GetSize();z2t++)
 
3752
                                {
 
3753
                                        a2 = (CxIntArray*)g2->m_oaAtoms[z2t];
 
3754
                                        for (z2a=0;z2a<a2->GetSize();z2a++)
 
3755
                                        {
 
3756
                                                if (m_iRefOrSec[0])
 
3757
                                                        vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g1->m_baAtomType[z1t]])->GetAt(a1->GetAt(z1a)));
 
3758
                                                                else vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g1->m_baAtomType[z1t]])->GetAt(a1->GetAt(z1a)));
 
3759
                                                if (m_iRefOrSec[1])
 
3760
                                                        vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g2->m_baAtomType[z2t]])->GetAt(a2->GetAt(z2a)));
 
3761
                                                                else vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g2->m_baAtomType[z2t]])->GetAt(a2->GetAt(z2a)));
 
3762
                        //                      mprintf("Vector z=%d, z1t=%d, z1a=%d, z2t=%d, z2a=%d.\n",z,z1t,z1a,z2t,z2a);
 
3763
                                        }
 
3764
                                }
 
3765
                        }
 
3766
                }
 
3767
        }
 
3768
        BXOUT;
 
3769
}
 
3770
 
 
3771
 
 
3772
void CVHDF::BuildAtomList(CSingleMolecule *ref, CSingleMolecule *obs, CxIntArray *vec)
 
3773
{
 
3774
        BXIN;
 
3775
        int z, z1t, z1a, z2t, z2a;
 
3776
        CAtomGroup *g1, *g2;
 
3777
        CxIntArray *a1, *a2;
 
3778
 
 
3779
        vec->RemoveAll_KeepSize();
 
3780
        for (z=0;z<m_oaVectors.GetSize()/2;z++)
 
3781
        {
 
3782
                g1 = (CAtomGroup*)m_oaVectors[z*2];
 
3783
                for (z1t=0;z1t<g1->m_baAtomType.GetSize();z1t++)
 
3784
                {
 
3785
                        a1 = (CxIntArray*)g1->m_oaAtoms[z1t];
 
3786
                        for (z1a=0;z1a<a1->GetSize();z1a++)
 
3787
                        {
 
3788
                                g2 = (CAtomGroup*)m_oaVectors[z*2+1];
 
3789
                                for (z2t=0;z2t<g2->m_baAtomType.GetSize();z2t++)
 
3790
                                {
 
3791
                                        a2 = (CxIntArray*)g2->m_oaAtoms[z2t];
 
3792
                                        for (z2a=0;z2a<a2->GetSize();z2a++)
 
3793
                                        {
 
3794
                                                if (m_iRefOrSec[0])
 
3795
                                                        vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g1->m_baAtomType[z1t]])->GetAt(a1->GetAt(z1a)));
 
3796
                                                                else vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g1->m_baAtomType[z1t]])->GetAt(a1->GetAt(z1a)));
 
3797
                                                if (m_iRefOrSec[1])
 
3798
                                                        vec->Add(((CxIntArray*)obs->m_oaAtomOffset[g2->m_baAtomType[z2t]])->GetAt(a2->GetAt(z2a)));
 
3799
                                                                else vec->Add(((CxIntArray*)ref->m_oaAtomOffset[g2->m_baAtomType[z2t]])->GetAt(a2->GetAt(z2a)));
 
3800
                                        }
 
3801
                                }
 
3802
                        }
 
3803
                }
 
3804
        }
 
3805
        BXOUT;
 
3806
}
 
3807
 
 
3808
 
 
3809
/*int FindAtom(char *s)
 
3810
{
 
3811
        BTIN;
 
3812
        int z;
 
3813
        for (z=0;z<g_oaAtoms.GetSize();z++)
 
3814
                if (mystricmp(s,((CAtom*)g_oaAtoms[z])->m_sName)==0)
 
3815
                {
 
3816
                        BTOUT; 
 
3817
                        return z;
 
3818
                }
 
3819
        BTOUT; 
 
3820
        return -1;
 
3821
}*/
 
3822
 
 
3823
 
 
3824
int CMolecule::FindAtomInMol(const char *s)
 
3825
{
 
3826
        BTIN;
 
3827
        int z;
 
3828
        for (z=0;z<m_baAtomIndex.GetSize();z++)
 
3829
                if (mystricmp(s,((CAtom*)g_oaAtoms[m_baAtomIndex[z]])->m_sName)==0)
 
3830
                {
 
3831
                        BTOUT; 
 
3832
                        return z;
 
3833
                }
 
3834
        BTOUT; 
 
3835
        return -1;
 
3836
}
 
3837
 
 
3838
 
 
3839
void CMolecule::BuildName()
 
3840
{
 
3841
        BTIN;
 
3842
        int z, z2;
 
3843
        char buf[16], buf2[256];
 
3844
 
 
3845
        if (m_bPseudo)
 
3846
        {
 
3847
                buf2[0] = '$';
 
3848
                buf2[1] = 0;
 
3849
        } else buf2[0] = 0;
 
3850
        for (z=0;z<g_oaAtoms.GetSize();z++)
 
3851
        {
 
3852
                for (z2=0;z2<m_baAtomIndex.GetSize();z2++)
 
3853
                {
 
3854
                        if (m_baAtomIndex[z2] != z)
 
3855
                                continue;
 
3856
                        if (m_waAtomCount[z2] > 1)
 
3857
                                sprintf(buf,"%s%d",((CAtom*)g_oaAtoms[z])->m_sName,m_waAtomCount[z2]);
 
3858
                        else sprintf(buf,"%s",((CAtom*)g_oaAtoms[z])->m_sName);
 
3859
                        strcat(buf2,buf);
 
3860
                }
 
3861
        }
 
3862
 
 
3863
        try { m_sName = new char[strlen(buf2)+1]; } catch(...) { m_sName = NULL; }
 
3864
        if (m_sName == NULL) NewException((double)(strlen(buf2)+1)*sizeof(char),__FILE__,__LINE__,__PRETTY_FUNCTION__);
 
3865
        
 
3866
        strcpy(m_sName,buf2);
 
3867
        BTOUT; 
 
3868
}
 
3869
 
 
3870
 
 
3871
bool CConditionGroup::Contains(int mol)
 
3872
{
 
3873
        BXIN;
 
3874
        int z;
 
3875
 
 
3876
        if (m_bInactive)
 
3877
                return m_bAlwaysTrue[mol];
 
3878
 
 
3879
        if (m_bInvertCondition)
 
3880
        {
 
3881
                if (m_bAlwaysTrue[mol])
 
3882
                {
 
3883
                        BXOUT;
 
3884
                        return false;
 
3885
                }
 
3886
                for (z=0;z<m_oaConditionSubGroups.GetSize();z++)
 
3887
                {
 
3888
                        if (((CConditionSubGroup*)m_oaConditionSubGroups[z])->Contains(mol))
 
3889
                        {
 
3890
                                BXOUT;
 
3891
                                return false;
 
3892
                        }
 
3893
                }
 
3894
                BXOUT;
 
3895
                return true;
 
3896
        } else
 
3897
        {
 
3898
                if (m_bAlwaysTrue[mol])
 
3899
                {
 
3900
                        BXOUT;
 
3901
                        return true;
 
3902
                }
 
3903
                for (z=0;z<m_oaConditionSubGroups.GetSize();z++)
 
3904
                {
 
3905
                        if (((CConditionSubGroup*)m_oaConditionSubGroups[z])->Contains(mol))
 
3906
                        {
 
3907
                                BXOUT;
 
3908
                                return true;
 
3909
                        }
 
3910
                }
 
3911
                BXOUT;
 
3912
                return false;
 
3913
        }
 
3914
}
 
3915
 
 
3916
 
 
3917
void CConditionGroup::MarkPassedAtoms(int om, bool passed)
 
3918
{
 
3919
        BXIN;
 
3920
        int z;
 
3921
//      int ti;
 
3922
 
 
3923
//      mprintf("######## OM %d ##########\n",om+1);
 
3924
 
 
3925
        for (z=0;z<g_iGesVirtAtomCount;z++)
 
3926
                g_baAtomPassedCondition[z] = 110; // 110 heisst: Atom kommt nicht in einer Condition vor
 
3927
 
 
3928
        for (z=0;z<m_oaConditionSubGroups.GetSize();z++)
 
3929
                ((CConditionSubGroup*)m_oaConditionSubGroups[z])->MarkPassedAtoms(om);
 
3930
 
 
3931
//      for (z=0;z<g_iGesVirtAtomCount;z++)
 
3932
//              mprintf("\nAtom %d: %d.",z+1,g_baAtomPassedCondition[z]);
 
3933
 
 
3934
//      ti = 0;
 
3935
        if (m_bInvertCondition)
 
3936
        {
 
3937
                for (z=0;z<g_iGesVirtAtomCount;z++)
 
3938
                {
 
3939
                        if (g_baAtomPassedCondition[z] != 100) // Entweder Condition nicht bestanden oder Atom kam gar nicht darin vor
 
3940
                        {
 
3941
//                              ti++;
 
3942
                                g_baAtomPassedCondition[z] = 1;
 
3943
//                              mprintf("%d: Ok\n",z+1);
 
3944
//                              mprintf("\n %d --> Wird genommen.",z+1);
 
3945
                        } else // Condition bestanden
 
3946
                        {
 
3947
        //                      mprintf("Atom %s%d nicht bestanden (%d).\n",((CAtom*)g_oaAtoms[g_waAtomRealElement[z]])->m_sName,g_waAtomMolNumber[z]+1,g_baAtomPassedCondition[z]);
 
3948
        //                      mprintf("\n%d erfuellt --> durchgefallen",z+1);
 
3949
                                g_baAtomPassedCondition[z] = 0;
 
3950
                        }
 
3951
                }
 
3952
        } else
 
3953
        {
 
3954
                for (z=0;z<g_iGesVirtAtomCount;z++)
 
3955
                {
 
3956
                        if (passed)
 
3957
                        {
 
3958
                                if (g_baAtomPassedCondition[z] >= 100) // Entweder Condition bestanden oder Atom kam gar nicht darin vor
 
3959
                                {
 
3960
//                                      ti++;
 
3961
                                        g_baAtomPassedCondition[z] = 1;
 
3962
                                } else // Condition nicht bestanden
 
3963
                                {
 
3964
                //                      mprintf("Atom %s%d nicht bestanden (%d).\n",((CAtom*)g_oaAtoms[g_waAtomRealElement[z]])->m_sName,g_waAtomMolNumber[z]+1,g_baAtomPassedCondition[z]);
 
3965
                                        g_baAtomPassedCondition[z] = 0;
 
3966
                                }
 
3967
                        } else
 
3968
                        {
 
3969
                                if (g_baAtomPassedCondition[z] == 100) // Condition bestanden
 
3970
                                {
 
3971
//                                      ti++;
 
3972
//                                      mprintf("### Atom %s[%d] %s%d bestanden (%d).\n",((CMolecule*)g_oaMolecules[g_waAtomMolIndex[z]])->m_sName,g_laAtomSMLocalIndex[z]+1,((CAtom*)g_oaAtoms[g_waAtomRealElement[z]])->m_sName,g_waAtomMolNumber[z]+1,g_baAtomPassedCondition[z]);
 
3973
                                        g_baAtomPassedCondition[z] = 0;
 
3974
                                } else // Entweder Condition nicht bestanden oder Atom kam gar nicht darin vor
 
3975
                                {
 
3976
//                                      mprintf("--- Atom %s[%d] %s%d nicht bestanden (%d).\n",((CMolecule*)g_oaMolecules[g_waAtomMolIndex[z]])->m_sName,g_laAtomSMLocalIndex[z]+1,((CAtom*)g_oaAtoms[g_waAtomRealElement[z]])->m_sName,g_waAtomMolNumber[z]+1,g_baAtomPassedCondition[z]);
 
3977
                                        g_baAtomPassedCondition[z] = 1;
 
3978
                                }
 
3979
                        }
 
3980
                }
 
3981
        }
 
3982
//      mprintf("\nMarked %d / %d atoms as enabled.",ti,g_iGesVirtAtomCount);
 
3983
 
 
3984
        BXOUT;
 
3985
}
 
3986
 
 
3987
 
 
3988
void CConditionGroup::ScanNeighborhoodAllOM(CTimeStep *t, CSingleMolecule *rm)
 
3989
{
 
3990
        BXIN;
 
3991
        int z, z2, t1, t2, i;
 
3992
 
 
3993
        if (m_bInactive)
 
3994
                return;
 
3995
 
 
3996
        for (z=0;z<m_oaConditionSubGroups.GetSize();z++)
 
3997
                ((CConditionSubGroup*)m_oaConditionSubGroups[z])->ScanNeighborhoodAllOM(t,rm);
 
3998
 
 
3999
        if (m_oaConditionSubGroups.GetSize() == 2)
 
4000
        {
 
4001
                for (z=0;z<((CMolecule*)g_oaMolecules[m_iShowMol])->m_laSingleMolIndex.GetSize();z++)
 
4002
                {
 
4003
                        t1 = 0;
 
4004
                        t2 = 0;
 
4005
                        for (z2=0;z2<((CConditionSubGroup*)m_oaConditionSubGroups[0])->m_oaConditions.GetSize();z2++)
 
4006
                                t1 += ((CNbSearch*)((CConditionSubGroup*)m_oaConditionSubGroups[0])->m_oaConditions[z2])->m_iCombPassCount[z];
 
4007
                        for (z2=0;z2<((CConditionSubGroup*)m_oaConditionSubGroups[1])->m_oaConditions.GetSize();z2++)
 
4008
                                t2 += ((CNbSearch*)((CConditionSubGroup*)m_oaConditionSubGroups[1])->m_oaConditions[z2])->m_iCombPassCount[z];
 
4009
                        m_pTable[t1*(((CConditionSubGroup*)m_oaConditionSubGroups[1])->m_iCombinations+1)+t2]++;
 
4010
                        m_fTableGes++;
 
4011
                }
 
4012
        }
 
4013
 
 
4014
        i = 0;
 
4015
        for (z=0;z<((CMolecule*)g_oaMolecules[m_iShowMol])->m_laSingleMolIndex.GetSize();z++)
 
4016
        {
 
4017
                m_fTotal++;
 
4018
                if (m_bInvertCondition)
 
4019
                {
 
4020
                        for (z2=0;z2<m_oaConditionSubGroups.GetSize();z2++)
 
4021
                                if (((CConditionSubGroup*)m_oaConditionSubGroups[z2])->Contains(z))
 
4022
                                        goto _nopass;
 
4023
                        m_fPassed++;
 
4024
                        m_iPassCounter[z]++;
 
4025
                        m_bAnyPassed = true;
 
4026
                } else
 
4027
                {
 
4028
                        for (z2=0;z2<m_oaConditionSubGroups.GetSize();z2++)
 
4029
                        {
 
4030
                                if (((CConditionSubGroup*)m_oaConditionSubGroups[z2])->Contains(z))
 
4031
                                {
 
4032
//                                      mprintf("passed[%d]++\n",z);
 
4033
                                        m_fPassed++;
 
4034
                                        m_iPassCounter[z]++;
 
4035
                                        m_bAnyPassed = true;
 
4036
                                        i++;
 
4037
                                        goto _nopass;
 
4038
                                }
 
4039
                        }
 
4040
                }
 
4041
_nopass:;
 
4042
        }
 
4043
        m_pHistogram[i]++;
 
4044
        m_iHistoGes++;
 
4045
 
 
4046
        BXOUT;
 
4047
}
 
4048
 
 
4049
 
 
4050
void CConditionGroup::PreScanNeighborhoodAllOM(CTimeStep *t, CSingleMolecule *rm)
 
4051
{
 
4052
        BXIN;
 
4053
        int z;
 
4054
 
 
4055
        if (m_bInactive)
 
4056
                return;
 
4057
 
 
4058
        for (z=0;z<m_oaConditionSubGroups.GetSize();z++)
 
4059
                ((CConditionSubGroup*)m_oaConditionSubGroups[z])->PreScanNeighborhoodAllOM(t,rm);
 
4060
 
 
4061
        BXOUT;
 
4062
}
 
4063
 
 
4064
 
 
4065
void CConditionGroup::Parse(int rm, int sm)
 
4066
{
 
4067
        BTIN;
 
4068
        CConditionSubGroup *sg;
 
4069
        int z;
 
4070
 
 
4071
        m_iShowMol = sm;
 
4072
        m_iRefMol = rm;
 
4073
 
 
4074
        try { m_bAlwaysTrue = new bool[((CMolecule*)g_oaMolecules[sm])->m_laSingleMolIndex.GetSize()]; } catch(...) { m_bAlwaysTrue = NULL; }
 
4075
        if (m_bAlwaysTrue == NULL) NewException((double)((CMolecule*)g_oaMolecules[sm])->m_laSingleMolIndex.GetSize()*sizeof(bool),__FILE__,__LINE__,__PRETTY_FUNCTION__);
 
4076
        
 
4077
        try { m_iPassCounter = new long[((CMolecule*)g_oaMolecules[sm])->m_laSingleMolIndex.GetSize()]; } catch(...) { m_iPassCounter = NULL; }
 
4078
        if (m_iPassCounter == NULL) NewException((double)((CMolecule*)g_oaMolecules[sm])->m_laSingleMolIndex.GetSize()*sizeof(long),__FILE__,__LINE__,__PRETTY_FUNCTION__);
 
4079
        
 
4080
        try { m_iOMPassCounter = new long[((CMolecule*)g_oaMolecules[sm])->m_laSingleMolIndex.GetSize()]; } catch(...) { m_iOMPassCounter = NULL; }
 
4081
        if (m_iOMPassCounter == NULL) NewException((double)((CMolecule*)g_oaMolecules[sm])->m_laSingleMolIndex.GetSize()*sizeof(long),__FILE__,__LINE__,__PRETTY_FUNCTION__);
 
4082
        
 
4083
        for (z=0;z<((CMolecule*)g_oaMolecules[sm])->m_laSingleMolIndex.GetSize();z++)
 
4084
        {
 
4085
                m_bAlwaysTrue[z] = false;
 
4086
                m_iPassCounter[z] = 0;
 
4087
                m_iOMPassCounter[z] = 0;
 
4088
        }
 
4089
 
 
4090
        try { m_iRMPassCounter = new long[((CMolecule*)g_oaMolecules[rm])->m_laSingleMolIndex.GetSize()]; } catch(...) { m_iRMPassCounter = NULL; }
 
4091
        if (m_iRMPassCounter == NULL) NewException((double)((CMolecule*)g_oaMolecules[rm])->m_laSingleMolIndex.GetSize()*sizeof(long),__FILE__,__LINE__,__PRETTY_FUNCTION__);
 
4092
        
 
4093
        for (z=0;z<((CMolecule*)g_oaMolecules[rm])->m_laSingleMolIndex.GetSize();z++)
 
4094
                m_iRMPassCounter[z] = 0;
 
4095
 
 
4096
        mprintf("Different sets of conditions are connected with OR (at least one of them has to be fulfilled).\n");
 
4097
        mprintf("Different conditions within one set are connected with AND (have to be fulfilled at the same time).\n");
 
4098
        mprintf("If you create 1 or 2 sets of conditions, a table with subcondition count populations will be printed.\n\n");
 
4099
_newset:
 
4100
        mprintf(YELLOW,">>> %d. set of conditions >>>\n",m_oaConditionSubGroups.GetSize()+1);
 
4101
 
 
4102
        try { sg = new CConditionSubGroup(); } catch(...) { sg = NULL; }
 
4103
        if (sg == NULL) NewException((double)sizeof(CConditionSubGroup),__FILE__,__LINE__,__PRETTY_FUNCTION__);
 
4104
        
 
4105
        sg->m_iShowMol = m_iShowMol;
 
4106
        sg->m_iNumber = m_oaConditionSubGroups.GetSize();
 
4107
        m_oaConditionSubGroups.Add(sg);
 
4108
        sg->Parse(rm,sm);
 
4109
        mprintf(YELLOW,"\n<<< End of %d. set of conditions <<<\n\n",m_oaConditionSubGroups.GetSize());
 
4110
        if (AskYesNo("    Enter an additional set of conditions (y/n)? [no] ",false))
 
4111
                goto _newset;
 
4112
        
 
4113
        m_bInvertCondition = AskYesNo("    Invert this condition (only add bin entries if failed) (y/n)? [no] ",false);
 
4114
 
 
4115
        if (m_oaConditionSubGroups.GetSize() == 2)
 
4116
        {
 
4117
                m_fTableGes = 0;
 
4118
 
 
4119
                try { m_pTable = new double[(((CConditionSubGroup*)m_oaConditionSubGroups[0])->m_iCombinations+1) * (((CConditionSubGroup*)m_oaConditionSubGroups[1])->m_iCombinations+1)]; } catch(...) { m_pTable = NULL; }
 
4120
                if (m_pTable == NULL) NewException((double)(((CConditionSubGroup*)m_oaConditionSubGroups[0])->m_iCombinations+1) * (((CConditionSubGroup*)m_oaConditionSubGroups[1])->m_iCombinations+1)*sizeof(double),__FILE__,__LINE__,__PRETTY_FUNCTION__);
 
4121
                
 
4122
                for (z=0;z<(((CConditionSubGroup*)m_oaConditionSubGroups[0])->m_iCombinations+1) * (((CConditionSubGroup*)m_oaConditionSubGroups[1])->m_iCombinations+1);z++)
 
4123
                        m_pTable[z] = 0;
 
4124
        }
 
4125
 
 
4126
/*      m_bNeedNbCountMode = false;
 
4127
        for (z=0;z<m_oaConditionSubGroups.GetSize();z++)
 
4128
        {
 
4129
                sg = (CConditionSubGroup*)m_oaConditionSubGroups[z];
 
4130
                for (z2=0;z2<sg->m_oaConditions.GetSize();z2++)
 
4131
                        if (((CNbSearch*)sg->m_oaConditions[z2])->m_iNbCountMin != -1)
 
4132
                                m_bNeedNbCountMode = true;
 
4133
        }*/
 
4134
        m_iHistoGes = 0;
 
4135
 
 
4136
        try {m_pHistogram = new unsigned long[((CMolecule*)g_oaMolecules[sm])->m_laSingleMolIndex.GetSize()+1]; } catch(...) { m_pHistogram = NULL; }
 
4137
        if (m_pHistogram == NULL) NewException((double)((CMolecule*)g_oaMolecules[sm])->m_laSingleMolIndex.GetSize()+1*sizeof(unsigned long),__FILE__,__LINE__,__PRETTY_FUNCTION__);
 
4138
        
 
4139
        for (z=0;z<((CMolecule*)g_oaMolecules[sm])->m_laSingleMolIndex.GetSize()+1;z++)
 
4140
                m_pHistogram[z] = 0;
 
4141
        BTOUT;
 
4142
}
 
4143
 
 
4144
 
 
4145
void CConditionGroup::PrintData()
 
4146
{
 
4147
        int z;
 
4148
 
 
4149
        mprintf(GREEN,"\n>>> Condition Data >>>\n\n");
 
4150
        mprintf("    %.0f of %.0f molecules passed the conditions (%.2f percent).\n",m_fPassed,m_fTotal,ZeroDivide(m_fPassed,m_fTotal)*100.0f);
 
4151
        if (m_fPassed == 0)
 
4152
        {
 
4153
                mprintf(YELLOW,"\n    No molecules at all passed the condition.\n");
 
4154
                mprintf("    This is probably not what you wanted.\n");
 
4155
        } else
 
4156
        {
 
4157
                mprintf(YELLOW,"\nList of reference molecules (%s) that passed the conditions:\n\n",((CMolecule*)g_oaMolecules[m_iRefMol])->m_sName);
 
4158
                for (z=0;z<((CMolecule*)g_oaMolecules[m_iRefMol])->m_laSingleMolIndex.GetSize();z++)
 
4159
                        if (m_iRMPassCounter[z] > 0)
 
4160
                                mprintf("  - %2d: %10.4f percent of the time (%d hits)\n",z+1,((double)m_iRMPassCounter[z])/g_iSteps*100.0,m_iRMPassCounter[z]);
 
4161
 
 
4162
                mprintf(YELLOW,"\nList of observed molecules (%s) that passed the conditions:\n\n",((CMolecule*)g_oaMolecules[m_iShowMol])->m_sName);
 
4163
                for (z=0;z<((CMolecule*)g_oaMolecules[m_iShowMol])->m_laSingleMolIndex.GetSize();z++)
 
4164
                        if (m_iOMPassCounter[z] > 0)
 
4165
                                mprintf("  - %2d: %10.4f percent of the time (%d hits)\n",z+1,((double)m_iOMPassCounter[z])/g_iSteps*100.0,m_iOMPassCounter[z]);
 
4166
        }
 
4167
        mprintf(YELLOW,"\nNeighbor count histogram:\n\n");
 
4168
        for (z=0;z<((CMolecule*)g_oaMolecules[m_iShowMol])->m_laSingleMolIndex.GetSize()+1;z++)
 
4169
                if (m_pHistogram[z] != 0)
 
4170
                        mprintf("  - %d Neighbors: %8.4f percent of the time (%d hits).\n",z,((double)m_pHistogram[z])/m_iHistoGes*100.0,m_pHistogram[z]);
 
4171
        mprintf(YELLOW,"\nListing for all sets of conditions:\n");
 
4172
        for (z=0;z<m_oaConditionSubGroups.GetSize();z++)
 
4173
                ((CConditionSubGroup*)m_oaConditionSubGroups[z])->PrintData();
 
4174
        mprintf(GREEN,"\n<<< End of Condition Data <<<\n\n");
 
4175
}
 
4176
 
 
4177
 
 
4178
void CConditionGroup::PrintData(char *s)
 
4179
{
 
4180
        int z;
 
4181
        FILE *a;
 
4182
 
 
4183
        mprintf(GREEN,"\n>>> Condition Data >>>\n\n");
 
4184
        mprintf("    %.0f of %.0f molecules passed the conditions (%.2f percent).\n",m_fPassed,m_fTotal,ZeroDivide(m_fPassed,m_fTotal)*100.0f);
 
4185
        if (m_fPassed == 0)
 
4186
        {
 
4187
                mprintf("\n    No molecules at all passed the condition.\n");
 
4188
                mprintf("    This is probably not what you wanted.\n");
 
4189
        }
 
4190
        mprintf("\nNeighbor count histogram:\n\n");
 
4191
        for (z=0;z<((CMolecule*)g_oaMolecules[m_iShowMol])->m_laSingleMolIndex.GetSize()+1;z++)
 
4192
                if (m_pHistogram[z] != 0)
 
4193
                        mprintf("  - %d Neighbors: %8.4f percent of the time (%d hits).\n",z,((double)m_pHistogram[z])/m_iHistoGes*100.0,m_pHistogram[z]);
 
4194
        mprintf("\n    Saving detailed condition data as \"%s\"...\n",s);
 
4195
 
 
4196
        a = OpenFileWrite(s,true);
 
4197
 
 
4198
        mfprintf(a,"\n>>> Condition Data >>>\n\n");
 
4199
        mfprintf(a,"    %.0f of %.0f molecules passed the conditions (%.2f percent).\n",m_fPassed,m_fTotal,ZeroDivide(m_fPassed,m_fTotal)*100.0f);
 
4200
        if (m_fPassed == 0)
 
4201
        {
 
4202
                mfprintf(a,"\n    No molecules at all passed the condition.\n");
 
4203
                mfprintf(a,"    This is probably not what you wanted.\n");
 
4204
        } else
 
4205
        {
 
4206
                mfprintf(a,"\nList of reference molecules (%s) that passed the conditions:\n\n",((CMolecule*)g_oaMolecules[m_iRefMol])->m_sName);
 
4207
                for (z=0;z<((CMolecule*)g_oaMolecules[m_iRefMol])->m_laSingleMolIndex.GetSize();z++)
 
4208
                        if (m_iRMPassCounter[z] > 0)
 
4209
                                mfprintf(a,"  - %2d: %10.4f percent of the time (%lu hits)\n",z+1,((double)m_iRMPassCounter[z])/g_iSteps*100.0,m_iRMPassCounter[z]);
 
4210
 
 
4211
                mfprintf(a,"\nList of observed molecules (%s) that passed the conditions:\n\n",((CMolecule*)g_oaMolecules[m_iShowMol])->m_sName);
 
4212
                for (z=0;z<((CMolecule*)g_oaMolecules[m_iShowMol])->m_laSingleMolIndex.GetSize();z++)
 
4213
                        if (m_iOMPassCounter[z] > 0)
 
4214
                                mfprintf(a,"  - %2d: %10.4f percent of the time (%lu hits)\n",z+1,((double)m_iOMPassCounter[z])/g_iSteps*100.0,m_iOMPassCounter[z]);
 
4215
        }
 
4216
        mfprintf(a,"\nNeighbor count histogram:\n\n");
 
4217
        for (z=0;z<((CMolecule*)g_oaMolecules[m_iShowMol])->m_laSingleMolIndex.GetSize()+1;z++)
 
4218
                if (m_pHistogram[z] != 0)
 
4219
                        mfprintf(a,"  - %d Neighbors: %8.4f percent of the time (%lu hits).\n",z,((double)m_pHistogram[z])/m_iHistoGes*100.0,m_pHistogram[z]);
 
4220
        mfprintf(a,"\nListing for all sets of conditions:\n");
 
4221
        for (z=0;z<m_oaConditionSubGroups.GetSize();z++)
 
4222
                ((CConditionSubGroup*)m_oaConditionSubGroups[z])->PrintData(a);
 
4223
        mfprintf(a,"\n<<< End of Condition Data <<<\n\n");
 
4224
 
 
4225
        fclose(a);
 
4226
        mprintf(GREEN,"\n<<< End of Condition Data <<<\n\n");
 
4227
}
 
4228
 
 
4229
 
 
4230
bool CConditionSubGroup::Contains(int mol)
 
4231
{
 
4232
        BXIN;
 
4233
        int z;
 
4234
 
 
4235
        for (z=0;z<m_oaConditions.GetSize();z++)
 
4236
        {
 
4237
                if (!((CNbSearch*)m_oaConditions[z])->m_bPassed[mol])
 
4238
                {
 
4239
                        BXOUT;
 
4240
                        return false;
 
4241
                }
 
4242
        }
 
4243
        BXOUT;
 
4244
        return true;
 
4245
}
 
4246
 
 
4247
 
 
4248
void CConditionSubGroup::MarkPassedAtoms(int om)
 
4249
{
 
4250
        int z, z2;
 
4251
 
 
4252
        for (z=0;z<g_iGesVirtAtomCount;z++)
 
4253
                m_bTempPassed[z] = false;
 
4254
 
 
4255
        for (z=0;z<m_oaConditions.GetSize();z++)
 
4256
        {
 
4257
                for (z2=0;z2<g_iGesVirtAtomCount;z2++)
 
4258
                        if (g_baAtomPassedCondition[z2] < 100)
 
4259
                                g_baAtomPassedCondition[z2] = 0;
 
4260
 
 
4261
                ((CNbSearch*)m_oaConditions[z])->MarkPassedAtoms(om);
 
4262
 
 
4263
                for (z2=0;z2<g_iGesVirtAtomCount;z2++)
 
4264
                        if (g_baAtomPassedCondition[z2] == 1)
 
4265
                                m_bTempPassed[z2] = true;
 
4266
        }
 
4267
 
 
4268
        for (z=0;z<g_iGesVirtAtomCount;z++)
 
4269
                if (m_bTempPassed[z])
 
4270
                        g_baAtomPassedCondition[z] = 100;
 
4271
}
 
4272
 
 
4273
 
 
4274
void CConditionSubGroup::ScanNeighborhoodAllOM(CTimeStep *t, CSingleMolecule *rm)
 
4275
{
 
4276
        int z, z2;
 
4277
 
 
4278
        for (z=0;z<m_oaConditions.GetSize();z++)
 
4279
                ((CNbSearch*)m_oaConditions[z])->ScanAllOM(rm,t);
 
4280
 
 
4281
        for (z=0;z<((CMolecule*)g_oaMolecules[m_iShowMol])->m_laSingleMolIndex.GetSize();z++)
 
4282
        {
 
4283
                m_fTotal++;
 
4284
                for (z2=0;z2<m_oaConditions.GetSize();z2++)
 
4285
                        if (!((CNbSearch*)m_oaConditions[z2])->m_bPassed[z])
 
4286
                                goto _nopass;
 
4287
                m_fPassed++;
 
4288
_nopass:;
 
4289
        }
 
4290
}
 
4291
 
 
4292
 
 
4293
void CConditionSubGroup::PreScanNeighborhoodAllOM(CTimeStep *t, CSingleMolecule *rm)
 
4294
{
 
4295
        int z;
 
4296
 
 
4297
        for (z=0;z<m_oaConditions.GetSize();z++)
 
4298
                ((CNbSearch*)m_oaConditions[z])->PreScanAllOM(rm,t);
 
4299
}
 
4300
 
 
4301
 
 
4302
void CConditionSubGroup::Parse(int rm, int sm)
 
4303
{
 
4304
        BTIN;
 
4305
        CNbSearch *n;
 
4306
 
 
4307
        m_iCombinations = 0;
 
4308
        do
 
4309
        {
 
4310
                try { n = new CNbSearch(); } catch(...) { n = NULL; }
 
4311
                if (n == NULL) NewException((double)sizeof(CNbSearch),__FILE__,__LINE__,__PRETTY_FUNCTION__);
 
4312
                
 
4313
                n->m_iNumber = m_oaConditions.GetSize();
 
4314
                m_oaConditions.Add(n);
 
4315
                n->Parse(rm,sm,false);
 
4316
                m_iCombinations += n->m_iCombinationsEnabled;
 
4317
        } while (AskYesNo("    Add another condition to this set of conditions (y/n)? [no] ",false));
 
4318
 
 
4319
        try { m_bTempPassed = new bool[g_iGesVirtAtomCount]; } catch(...) { m_bTempPassed = NULL; }
 
4320
        if (m_bTempPassed == NULL) NewException((double)g_iGesVirtAtomCount*sizeof(bool),__FILE__,__LINE__,__PRETTY_FUNCTION__);
 
4321
        
 
4322
        BTOUT;
 
4323
}
 
4324
 
 
4325
 
 
4326
void CADF::ParseCondition(int rm, bool nocrit)
 
4327
{
 
4328
        BTIN;
 
4329
        char buf[256];
 
4330
        int z, z2, ti;
 
4331
        CAtomGroup *ag;
 
4332
 
 
4333
        mprintf(WHITE,"\n>>> Angular Condition >>>\n");
 
4334
        for (z=0;z<2;z++)
 
4335
                m_iVecType[z] = 0;
 
4336
        z2 = 0;
 
4337
        m_iCombinations = 0;
 
4338
        do {
 
4339
                ti = 1;
 
4340
                if (z2 != 0)
 
4341
                        mprintf("\n    %d. set of vectors\n\n",z2+1);
 
4342
                for (z=0;z<2;z++)
 
4343
                {
 
4344
/*                      if (z == 1)
 
4345
                                m_bSameFoot = AskYesNo("    Should the base points of the 1st and 2nd vectors always be equal (y/n)? [no] ",false);
 
4346
                                        else m_bSameFoot = false;*/
 
4347
                        m_bOrtho[z] = (AskRangeInteger("\n    Should the %d. vector connect two points (0) or stand perpendicular on 3 points (1)? [0] ",0,1,0,z+1) != 0);
 
4348
                        mprintf("\n");
 
4349
                        if (m_bOrtho[z])
 
4350
                        {
 
4351
/*                              if (m_bSameFoot && (z == 1))
 
4352
                                {
 
4353
                                        m_iRefOrSec[1][0] = m_iRefOrSec[0][0];
 
4354
                                        m_oaVectors.Add(NULL);
 
4355
                                } else*/
 
4356
                                {
 
4357
_ax1:                           if (m_iShowMol != -1)
 
4358
                                                m_iRefOrSec[z][0] = AskRangeInteger("    Take atom(s) in base point from 1st mol. %s (0) or from 2nd mol. %s (1)? [%d] ",0,1,z,((CMolecule*)g_oaMolecules[rm])->m_sName,((CMolecule*)g_oaMolecules[m_iShowMol])->m_sName,z);
 
4359
                                                        else m_iRefOrSec[z][0] = 0;
 
4360
                                        mprintf("      Enter atom(s) in the base point (e.g. C7): ");
 
4361
                                        inpprintf("! Enter atom(s) in the base point (e.g. C7):\n");
 
4362
                                        myget(buf);
 
4363
 
 
4364
                                        try { ag = new CAtomGroup(); } catch(...) { ag = NULL; }
 
4365
                                        if (ag == NULL) NewException((double)sizeof(CAtomGroup),__FILE__,__LINE__,__PRETTY_FUNCTION__);
 
4366
 
 
4367
                                        if (!ag->ParseAtoms((!m_iRefOrSec[z][0])?(CMolecule*)g_oaMolecules[rm]:(CMolecule*)g_oaMolecules[m_iShowMol],buf))
 
4368
                                        {
 
4369
                                                eprintf("Wrong input.\n");
 
4370
                                                inpprintf("! Wrong input.\n");
 
4371
                                                delete ag;
 
4372
                                                goto _ax1;
 
4373
                                        }
 
4374
                                        m_oaVectors.Add(ag);
 
4375
                                        ti *= ag->m_iAtomGes;
 
4376
                                }
 
4377
_ax2:                   if (m_iShowMol != -1)
 
4378
                                        m_iRefOrSec[z][1] = AskRangeInteger("   Take 2nd atom(s) of normal plane from 1st mol. %s (0) or from 2nd mol. %s (1)? [%d] ",0,1,z,((CMolecule*)g_oaMolecules[rm])->m_sName,((CMolecule*)g_oaMolecules[m_iShowMol])->m_sName,z);
 
4379
                                                else m_iRefOrSec[z][1] = 0;
 
4380
                                mprintf("      Enter 2nd atom(s) of normal plane (e.g. C7): ");
 
4381
                                inpprintf("! Enter 2nd atom(s) of normal plane (e.g. C7):\n");
 
4382
                                myget(buf);
 
4383
 
 
4384
                                try { ag = new CAtomGroup(); } catch(...) { ag = NULL; }
 
4385
                                if (ag == NULL) NewException((double)sizeof(CAtomGroup),__FILE__,__LINE__,__PRETTY_FUNCTION__);
 
4386
 
 
4387
                                if (!ag->ParseAtoms((!m_iRefOrSec[z][1])?(CMolecule*)g_oaMolecules[rm]:(CMolecule*)g_oaMolecules[m_iShowMol],buf))
 
4388
                                {
 
4389
                                        eprintf("Wrong input.\n");
 
4390
                                        inpprintf("! Wrong input.\n");
 
4391
                                        delete ag;
 
4392
                                        goto _ax2;
 
4393
                                }
 
4394
                                m_oaVectors.Add(ag);
 
4395
                                ti *= ag->m_iAtomGes;
 
4396
_ax3:                   if (m_iShowMol != -1)
 
4397
                                        m_iRefOrSec[z][2] = AskRangeInteger("    Take 3rd atom(s) of normal plane from 1st mol. %s (0) or from 2nd mol. %s (1)? [%d] ",0,1,z,((CMolecule*)g_oaMolecules[rm])->m_sName,((CMolecule*)g_oaMolecules[m_iShowMol])->m_sName,z);
 
4398
                                                else m_iRefOrSec[z][2] = 0;
 
4399
                                mprintf("      Enter 3rd atom(s) of normal plane (e.g. C7): ");
 
4400
                                inpprintf("! Enter 3rd atom(s) of normal plane (e.g. C7):\n");
 
4401
                                myget(buf);
 
4402
 
 
4403
                                try { ag = new CAtomGroup(); } catch(...) { ag = NULL; }
 
4404
                                if (ag == NULL) NewException((double)sizeof(CAtomGroup),__FILE__,__LINE__,__PRETTY_FUNCTION__);
 
4405
 
 
4406
                                if (!ag->ParseAtoms((!m_iRefOrSec[z][2])?(CMolecule*)g_oaMolecules[rm]:(CMolecule*)g_oaMolecules[m_iShowMol],buf))
 
4407
                                {
 
4408
                                        eprintf("Wrong input.\n");
 
4409
                                        inpprintf("! Wrong input.\n");
 
4410
                                        delete ag;
 
4411
                                        goto _ax3;
 
4412
                                }
 
4413
                                m_oaVectors.Add(ag);
 
4414
                                ti *= ag->m_iAtomGes;
 
4415
                        } else // IF NOT ORTHO
 
4416
                        {
 
4417
/*                              if (m_bSameFoot && (z == 1))
 
4418
                                {
 
4419
                                        m_iRefOrSec[1][0] = m_iRefOrSec[0][0];
 
4420
                                        m_oaVectors.Add(NULL);
 
4421
                                } else*/
 
4422
                                {
 
4423
_ax4:                           if (m_iShowMol != -1)
 
4424
                                                m_iRefOrSec[z][0] = AskRangeInteger("    Take atom(s) in base point from 1st mol. %s (0) or from 2nd mol. %s (1)? [%d] ",0,1,z,((CMolecule*)g_oaMolecules[rm])->m_sName,((CMolecule*)g_oaMolecules[m_iShowMol])->m_sName,z);
 
4425
                                                        else m_iRefOrSec[z][0] = 0;
 
4426
                                        mprintf("      Enter atom(s) in the base point (e.g. C7): ");
 
4427
                                        inpprintf("! Enter atom(s) in the base point (e.g. C7):\n");
 
4428
                                        myget(buf);
 
4429
 
 
4430
                                        try { ag = new CAtomGroup(); } catch(...) { ag = NULL; }
 
4431
                                        if (ag == NULL) NewException((double)sizeof(CAtomGroup),__FILE__,__LINE__,__PRETTY_FUNCTION__);
 
4432
 
 
4433
                                        if (!ag->ParseAtoms((!m_iRefOrSec[z][0])?(CMolecule*)g_oaMolecules[rm]:(CMolecule*)g_oaMolecules[m_iShowMol],buf))
 
4434
                                        {
 
4435
                                                eprintf("Wrong input.\n");
 
4436
                                                inpprintf("! Wrong input.\n");
 
4437
                                                delete ag;
 
4438
                                                goto _ax4;
 
4439
                                        }
 
4440
                                        m_oaVectors.Add(ag);
 
4441
                                        ti *= ag->m_iAtomGes;
 
4442
                                } // END IF NOT SAMEFOOT
 
4443
_ax5:                   if (m_iShowMol != -1)
 
4444
                                        m_iRefOrSec[z][1] = AskRangeInteger("    Take atom(s) in tip point from 1st mol. %s (0) or from 2nd mol. %s (1)? [%d] ",0,1,z,((CMolecule*)g_oaMolecules[rm])->m_sName,((CMolecule*)g_oaMolecules[m_iShowMol])->m_sName,z);
 
4445
                                                else m_iRefOrSec[z][1] = 0;
 
4446
                                mprintf("      Enter atom(s) in the tip point (e.g. C7): ");
 
4447
                                inpprintf("! Enter atom(s) in the tip point (e.g. C7):\n");
 
4448
                                myget(buf);
 
4449
 
 
4450
                                try { ag = new CAtomGroup(); } catch(...) { ag = NULL; }
 
4451
                                if (ag == NULL) NewException((double)sizeof(CAtomGroup),__FILE__,__LINE__,__PRETTY_FUNCTION__);
 
4452
 
 
4453
                                if (!ag->ParseAtoms((!m_iRefOrSec[z][1])?(CMolecule*)g_oaMolecules[rm]:(CMolecule*)g_oaMolecules[m_iShowMol],buf))
 
4454
                                {
 
4455
                                        eprintf("Wrong input.\n");
 
4456
                                        inpprintf("! Wrong input.\n");
 
4457
                                        delete ag;
 
4458
                                        goto _ax5;
 
4459
                                }
 
4460
                                m_oaVectors.Add(ag);
 
4461
                                ti *= ag->m_iAtomGes;
 
4462
                                m_oaVectors.Add(NULL);
 
4463
                        } // END IF NOT ORTHO
 
4464
                } // END FOR 0..1
 
4465
                m_iCombinations += ti;
 
4466
                z2++;
 
4467
        } while (AskYesNo("\n    Enter another set of vectors (y/n)? [no] ",false));
 
4468
        if (!nocrit)
 
4469
        {
 
4470
                do {
 
4471
                        m_faMinMaxAngle.Add(AskFloat("    Enter minimal angle between the vectors in degree: [0.0] ",0.0f));
 
4472
                        m_faMinMaxAngle.Add(AskFloat("    Enter maximal angle between the vectors in degree: [180.0] ",180.0f));
 
4473
                } while (AskYesNo("    Enter another angle interval (y/n)? [no] ",false));
 
4474
        } else
 
4475
        {
 
4476
                m_faMinMaxAngle.Add(0.0f);
 
4477
                m_faMinMaxAngle.Add(180.0f);
 
4478
        }
 
4479
        mprintf(WHITE,"\n<<< End of Angular Condition <<<\n\n");
 
4480
        BTOUT;
 
4481
}
 
4482
 
 
4483
 
 
4484
void CADF::ParseConditionGrid(int rm, int gridmode)
 
4485
{
 
4486
        BTIN;
 
4487
        char buf[256];
 
4488
        int z, z2, ti;
 
4489
        CAtomGroup *ag;
 
4490
 
 
4491
        mprintf(WHITE,"\n>>> Angular Condition >>>\n");
 
4492
        for (z=0;z<2;z++)
 
4493
                m_iVecType[z] = 0;
 
4494
        z2 = 0;
 
4495
        m_iCombinations = 0;
 
4496
        do {
 
4497
                ti = 1;
 
4498
                if (z2 != 0)
 
4499
                        mprintf("\n    %d. set of vectors\n\n",z2+1);
 
4500
                for (z=0;z<2;z++)
 
4501
                {
 
4502
/*                      if (z == 1)
 
4503
                                m_bSameFoot = AskYesNo("    Should the base points of the 1st and 2nd vectors always be equal (y/n)? [no] ",false);
 
4504
                                        else m_bSameFoot = false;*/
 
4505
                        m_bOrtho[z] = (AskRangeInteger("\n    Should the %d. vector connect two points (0) or stand perpendicular on 3 points (1)? [0] ",0,1,0,z+1) != 0);
 
4506
                        mprintf("\n");
 
4507
                        if (m_bOrtho[z])
 
4508
                        {
 
4509
/*                              if (m_bSameFoot && (z == 1))
 
4510
                                {
 
4511
                                        m_iRefOrSec[1][0] = m_iRefOrSec[0][0];
 
4512
                                        m_oaVectors.Add(NULL);
 
4513
                                } else*/
 
4514
                                {
 
4515
_ax1:                           if (m_iShowMol != -1)
 
4516
                                                m_iRefOrSec[z][0] = AskRangeInteger("    Take atom(s) in base point from 1st mol. %s (0) or from 2nd mol. %s (1)? [%d] ",0,1,z,((CMolecule*)g_oaMolecules[rm])->m_sName,((CMolecule*)g_oaMolecules[m_iShowMol])->m_sName,z);
 
4517
                                                        else m_iRefOrSec[z][0] = 0;
 
4518
                                        mprintf("      Enter atom(s) in the base point (e.g. C7): ");
 
4519
                                        inpprintf("! Enter atom(s) in the base point (e.g. C7):\n");
 
4520
                                        myget(buf);
 
4521
 
 
4522
                                        try { ag = new CAtomGroup(); } catch(...) { ag = NULL; }
 
4523
                                        if (ag == NULL) NewException((double)sizeof(CAtomGroup),__FILE__,__LINE__,__PRETTY_FUNCTION__);
 
4524
 
 
4525
                                        m_oaVectors.Add(ag);
 
4526
                                        if (!ag->ParseAtoms((!m_iRefOrSec[z][0])?(CMolecule*)g_oaMolecules[rm]:(CMolecule*)g_oaMolecules[m_iShowMol],buf))
 
4527
                                        {
 
4528
                                                eprintf("Wrong input.\n");
 
4529
                                                inpprintf("! Wrong input.\n");
 
4530
                                                goto _ax1;
 
4531
                                        }
 
4532
                                        ti *= ag->m_iAtomGes;
 
4533
                                }
 
4534
_ax2:                   if (m_iShowMol != -1)
 
4535
                                        m_iRefOrSec[z][1] = AskRangeInteger("   Take 2nd atom(s) of normal plane from 1st mol. %s (0) or from 2nd mol. %s (1)? [%d] ",0,1,z,((CMolecule*)g_oaMolecules[rm])->m_sName,((CMolecule*)g_oaMolecules[m_iShowMol])->m_sName,z);
 
4536
                                                else m_iRefOrSec[z][1] = 0;
 
4537
                                mprintf("      Enter 2nd atom(s) of normal plane (e.g. C7): ");
 
4538
                                inpprintf("! Enter 2nd atom(s) of normal plane (e.g. C7):\n");
 
4539
                                myget(buf);
 
4540
 
 
4541
                                try { ag = new CAtomGroup(); } catch(...) { ag = NULL; }
 
4542
                                if (ag == NULL) NewException((double)sizeof(CAtomGroup),__FILE__,__LINE__,__PRETTY_FUNCTION__);
 
4543
 
 
4544
                                m_oaVectors.Add(ag);
 
4545
                                if (!ag->ParseAtoms((!m_iRefOrSec[z][1])?(CMolecule*)g_oaMolecules[rm]:(CMolecule*)g_oaMolecules[m_iShowMol],buf))
 
4546
                                {
 
4547
                                        eprintf("Wrong input.\n");
 
4548
                                        inpprintf("! Wrong input.\n");
 
4549
                                        goto _ax2;
 
4550
                                }
 
4551
                                ti *= ag->m_iAtomGes;
 
4552
_ax3:                   if (m_iShowMol != -1)
 
4553
                                        m_iRefOrSec[z][2] = AskRangeInteger("    Take 3rd atom(s) of normal plane from 1st mol. %s (0) or from 2nd mol. %s (1)? [%d] ",0,1,z,((CMolecule*)g_oaMolecules[rm])->m_sName,((CMolecule*)g_oaMolecules[m_iShowMol])->m_sName,z);
 
4554
                                                else m_iRefOrSec[z][2] = 0;
 
4555
                                mprintf("      Enter 3rd atom(s) of normal plane (e.g. C7): ");
 
4556
                                inpprintf("! Enter 3rd atom(s) of normal plane (e.g. C7):\n");
 
4557
                                myget(buf);
 
4558
 
 
4559
                                try { ag = new CAtomGroup(); } catch(...) { ag = NULL; }
 
4560
                                if (ag == NULL) NewException((double)sizeof(CAtomGroup),__FILE__,__LINE__,__PRETTY_FUNCTION__);
 
4561
 
 
4562
                                m_oaVectors.Add(ag);
 
4563
                                if (!ag->ParseAtoms((!m_iRefOrSec[z][2])?(CMolecule*)g_oaMolecules[rm]:(CMolecule*)g_oaMolecules[m_iShowMol],buf))
 
4564
                                {
 
4565
                                        eprintf("Wrong input.\n");
 
4566
                                        inpprintf("! Wrong input.\n");
 
4567
                                        goto _ax3;
 
4568
                                }
 
4569
                                ti *= ag->m_iAtomGes;
 
4570
                        } else // IF NOT ORTHO
 
4571
                        {
 
4572
/*                              if (m_bSameFoot && (z == 1))
 
4573
                                {
 
4574
                                        m_iRefOrSec[1][0] = m_iRefOrSec[0][0];
 
4575
                                        m_oaVectors.Add(NULL);
 
4576
                                } else*/
 
4577
                                {
 
4578
_ax4:                           if (m_iShowMol != -1)
 
4579
                                                m_iRefOrSec[z][0] = AskRangeInteger("    Take atom(s) in base point from 1st mol. %s (0) or from 2nd mol. %s (1)? [%d] ",0,1,z,((CMolecule*)g_oaMolecules[rm])->m_sName,((CMolecule*)g_oaMolecules[m_iShowMol])->m_sName,z);
 
4580
                                                        else m_iRefOrSec[z][0] = 0;
 
4581
                                        mprintf("      Enter atom(s) in the base point (e.g. C7): ");
 
4582
                                        inpprintf("! Enter atom(s) in the base point (e.g. C7):\n");
 
4583
                                        myget(buf);
 
4584
 
 
4585
                                        try { ag = new CAtomGroup(); } catch(...) { ag = NULL; }
 
4586
                                        if (ag == NULL) NewException((double)sizeof(CAtomGroup),__FILE__,__LINE__,__PRETTY_FUNCTION__);
 
4587
 
 
4588
                                        m_oaVectors.Add(ag);
 
4589
                                        if (!ag->ParseAtoms((!m_iRefOrSec[z][0])?(CMolecule*)g_oaMolecules[rm]:(CMolecule*)g_oaMolecules[m_iShowMol],buf))
 
4590
                                        {
 
4591
                                                eprintf("Wrong input.\n");
 
4592
                                                inpprintf("! Wrong input.\n");
 
4593
                                                goto _ax4;
 
4594
                                        }
 
4595
                                        ti *= ag->m_iAtomGes;
 
4596
                                } // END IF NOT SAMEFOOT
 
4597
_ax5:                   if (m_iShowMol != -1)
 
4598
                                        m_iRefOrSec[z][1] = AskRangeInteger("    Take atom(s) in tip point from 1st mol. %s (0) or from 2nd mol. %s (1)? [%d] ",0,1,z,((CMolecule*)g_oaMolecules[rm])->m_sName,((CMolecule*)g_oaMolecules[m_iShowMol])->m_sName,z);
 
4599
                                                else m_iRefOrSec[z][1] = 0;
 
4600
                                mprintf("      Enter atom(s) in the tip point (e.g. C7): ");
 
4601
                                inpprintf("! Enter atom(s) in the tip point (e.g. C7):\n");
 
4602
                                myget(buf);
 
4603
 
 
4604
                                try { ag = new CAtomGroup(); } catch(...) { ag = NULL; }
 
4605
                                if (ag == NULL) NewException((double)sizeof(CAtomGroup),__FILE__,__LINE__,__PRETTY_FUNCTION__);
 
4606
 
 
4607
                                m_oaVectors.Add(ag);
 
4608
                                if (!ag->ParseAtoms((!m_iRefOrSec[z][1])?(CMolecule*)g_oaMolecules[rm]:(CMolecule*)g_oaMolecules[m_iShowMol],buf))
 
4609
                                {
 
4610
                                        eprintf("Wrong input.\n");
 
4611
                                        inpprintf("! Wrong input.\n");
 
4612
                                        goto _ax5;
 
4613
                                }
 
4614
                                ti *= ag->m_iAtomGes;
 
4615
                                m_oaVectors.Add(NULL);
 
4616
                        } // END IF NOT ORTHO
 
4617
                } // END FOR 0..1
 
4618
                m_iCombinations += ti;
 
4619
                z2++;
 
4620
        } while (AskYesNo("\n    Enter another set of vectors (y/n)? [no] ",false));
 
4621
        if ((gridmode == 1) || (gridmode == 6))
 
4622
        {
 
4623
                m_faMinMaxAngle.Add(AskFloat("    Enter minimal angle between the vectors in degree: [0.0] ",0.0f));
 
4624
                m_faMinMaxAngle.Add(AskFloat("    Enter maximal angle between the vectors in degree: [180.0] ",180.0f));
 
4625
        } else
 
4626
        {
 
4627
                m_faMinMaxAngle.Add(0.0f);
 
4628
                m_faMinMaxAngle.Add(180.0f);
 
4629
        }
 
4630
        mprintf(WHITE,"\n<<< End of Angular Condition <<<\n\n");
 
4631
        BTOUT;
 
4632
}
 
4633
 
 
4634
 
 
4635
void CADF::ParseCondition_OnlyValues()
 
4636
{
 
4637
        BTIN;
 
4638
        int z;
 
4639
 
 
4640
        mprintf("    Angular condition between vectors:\n");
 
4641
        for (z=0;z<m_oaVectors.GetSize()/6;z++)
 
4642
        {
 
4643
                mprintf("      ");
 
4644
                if (m_oaVectors[z*6+2] != NULL)
 
4645
                        mprintf("normal(%s, %s, %s)",((CAtomGroup*)m_oaVectors[z*6])->m_sName,((CAtomGroup*)m_oaVectors[z*6+1])->m_sName,((CAtomGroup*)m_oaVectors[z*6+2])->m_sName);
 
4646
                                else mprintf("(%s --> %s)",((CAtomGroup*)m_oaVectors[z*6])->m_sName,((CAtomGroup*)m_oaVectors[z*6+1])->m_sName);
 
4647
                mprintf(" and ");
 
4648
                if (m_oaVectors[z*6+5] != NULL)
 
4649
                        mprintf("normal(%s, %s, %s)",((CAtomGroup*)m_oaVectors[z*6+3])->m_sName,((CAtomGroup*)m_oaVectors[z*6+4])->m_sName,((CAtomGroup*)m_oaVectors[z*6+5])->m_sName);
 
4650
                                else mprintf("(%s --> %s)",((CAtomGroup*)m_oaVectors[z*6+3])->m_sName,((CAtomGroup*)m_oaVectors[z*6+4])->m_sName);
 
4651
                mprintf("\n");
 
4652
        }
 
4653
        for (z=0;z<m_faMinMaxAngle.GetSize()/2;z++)
 
4654
        {
 
4655
                mprintf("    Interval %d:\n",z+1,m_faMinMaxAngle.GetSize()/2);
 
4656
                m_faMinMaxAngle[z*2] = AskFloat("      Enter minimal angle between the vectors in degree: [0.0] ",0.0f);
 
4657
                m_faMinMaxAngle[z*2+1] = AskFloat("      Enter maximal angle between the vectors in degree: [180.0] ",180.0f);
 
4658
        } 
 
4659
//      mprintf(WHITE,"\n<<< End of Angular Condition <<<\n\n");
 
4660
        BTOUT;
 
4661
}
 
4662
 
 
4663
 
 
4664
CObservation::CObservation()
 
4665
{
 
4666
        m_pConditions = NULL;
 
4667
        m_pConditionsOM2 = NULL;
 
4668
        m_pMSD = NULL;
 
4669
        m_pSDF = NULL;
 
4670
        m_pCDF = NULL;
 
4671
        m_pVACF = NULL;
 
4672
        m_pDipACF = NULL;
 
4673
        m_pADF = NULL;
 
4674
        m_pDDF = NULL;
 
4675
        m_pRDF = NULL;
 
4676
        m_pDipDF = NULL;
4651
4677
        m_pVDF = NULL;
4652
 
        m_bBinOnlyPassedAtoms = false;
4653
 
        m_bBinOnlyNotPassedAtoms = false;
4654
 
 
4655
 
        m_waSaveRefList.SetName("CObservation::m_waSaveRefList");
4656
 
        m_waSaveShowList.SetName("CObservation::m_waSaveShowList");
4657
 
        m_waObsRefList.SetName("CObservation::m_waObsRefList");
4658
 
        m_waObsShowList.SetName("CObservation::m_waObsShowList");
4659
 
        m_waObsShow2List.SetName("CObservation::m_waObsShow2List");
4660
 
        m_waDecompTypeRefOffs.SetName("CObservation::m_waDecompTypeRefOffs");
4661
 
        m_waDecompTypeObsOffs.SetName("CObservation::m_waDecompTypeObsOffs");
4662
 
        m_waDecompTypeRefList.SetName("CObservation::m_waDecompTypeRefList");
4663
 
        m_waDecompTypeObsList.SetName("CObservation::m_waDecompTypeObsList");
4664
 
        m_iaRMRegions.SetName("CObservation::m_iaRMRegions");
4665
 
        m_iaOM1Regions.SetName("CObservation::m_iaOM1Regions");
4666
 
        m_iaOM2Regions.SetName("CObservation::m_iaOM2Regions");
4667
 
}
4668
 
 
4669
 
 
4670
 
CObservation::~CObservation()
4671
 
{
4672
 
        int z;
4673
 
 
4674
 
        if (m_pConditions != NULL)
4675
 
        {
4676
 
                delete m_pConditions;
4677
 
                m_pConditions = NULL;
4678
 
        }
4679
 
        if (m_pMSD != NULL)
4680
 
        {
4681
 
                delete m_pMSD;
4682
 
                m_pMSD = NULL;
4683
 
        }
4684
 
        if (m_pSDF != NULL)
4685
 
        {
4686
 
                delete m_pSDF;
4687
 
                m_pSDF = NULL;
4688
 
        }
4689
 
        if (m_pCDF != NULL)
4690
 
        {
4691
 
                delete m_pCDF;
4692
 
                m_pCDF = NULL;
4693
 
        }
4694
 
        if (m_pVACF != NULL)
4695
 
        {
4696
 
                delete m_pVACF;
4697
 
                m_pVACF = NULL;
4698
 
        }
4699
 
        if (m_pDipACF != NULL)
4700
 
        {
4701
 
                delete m_pDipACF;
4702
 
                m_pDipACF = NULL;
4703
 
        }
4704
 
 
4705
 
        if (m_pRDF != NULL)
4706
 
        {
4707
 
                for (z=0;z<g_iCDFChannels;z++)
4708
 
                {
4709
 
                        if (m_pRDF[z] != NULL)
4710
 
                        {
4711
 
                                delete m_pRDF[z];
4712
 
                                m_pRDF[z] = NULL;
4713
 
                        }
4714
 
                }
4715
 
                delete[] m_pRDF;
4716
 
                m_pRDF = NULL;
4717
 
        }
4718
 
        if (m_pADF != NULL)
4719
 
        {
4720
 
                for (z=0;z<g_iCDFChannels;z++)
4721
 
                {
4722
 
                        if (m_pADF[z] != NULL)
4723
 
                        {
4724
 
                                delete m_pADF[z];
4725
 
                                m_pADF[z] = NULL;
4726
 
                        }
4727
 
                }
4728
 
                delete[] m_pADF;
4729
 
                m_pADF = NULL;
4730
 
        }
4731
 
        if (m_pDDF != NULL)
4732
 
        {
4733
 
                for (z=0;z<g_iCDFChannels;z++)
4734
 
                {
4735
 
                        if (m_pDDF[z] != NULL)
4736
 
                        {
4737
 
                                delete m_pDDF[z];
4738
 
                                m_pDDF[z] = NULL;
4739
 
                        }
4740
 
                }
4741
 
                delete[] m_pDDF;
4742
 
                m_pDDF = NULL;
4743
 
        }
4744
 
        if (m_pDipDF != NULL)
4745
 
        {
4746
 
                for (z=0;z<g_iCDFChannels;z++)
4747
 
                {
4748
 
                        if (m_pDipDF[z] != NULL)
4749
 
                        {
4750
 
                                delete m_pDipDF[z];
4751
 
                                m_pDipDF[z] = NULL;
4752
 
                        }
4753
 
                }
4754
 
                delete[] m_pDipDF;
4755
 
                m_pDipDF = NULL;
4756
 
        }
4757
 
        if (m_pVDF != NULL)
4758
 
        {
4759
 
                for (z=0;z<g_iCDFChannels;z++)
4760
 
                {
4761
 
                        if (m_pVDF[z] != NULL)
4762
 
                        {
4763
 
                                delete m_pVDF[z];
4764
 
                                m_pVDF[z] = NULL;
4765
 
                        }
4766
 
                }
4767
 
                delete[] m_pVDF;
4768
 
                m_pVDF = NULL;
4769
 
        }
4770
 
}
4771
 
 
4772
 
 
4773
 
void CSingleMolecule::BuildAtomCodes()
4774
 
{
4775
 
        int z, z2, c1, c2, i;
4776
 
        double ac;
4777
 
        CMolAtom *ma;
4778
 
 
4779
 
        // Die Anfangswerte der AtomCodes: [Ordnungszahl] * 10.0 + [Zahl der Nicht-Wasserstoff-Bindungen]
4780
 
        for (z=0;z<m_oaMolAtoms.GetSize();z++)
4781
 
        {
4782
 
                ma = (CMolAtom*)m_oaMolAtoms[z];
4783
 
                ma->m_fAtomCode = 10.0 * ((CAtom*)g_oaAtoms[m_baAtomIndex[ma->m_iType]])->m_pElement->m_fMass;
4784
 
 
4785
 
                i = 0;
4786
 
                for (z2=0;z2<ma->m_oaBonds.GetSize();z2++)
4787
 
                {
4788
 
                        // Alle Wasserstoff-Atome ueberspringen
4789
 
                        if (((CAtom*)g_oaAtoms[m_baAtomIndex[((CMolAtom*)ma->m_oaBonds[z2])->m_iType]])->m_pElement->m_fMass < 4.5)
4790
 
                                continue;
4791
 
                        ma->m_fAtomCode++;
4792
 
                        i++;
4793
 
                }
4794
 
 
4795
 
                if (g_bVerbose)
4796
 
                        mprintf("    Atom %d (%s%d): 10.0 * %.2f + %d = %.2f\n",z+1,((CAtom*)g_oaAtoms[m_baAtomIndex[ma->m_iType]])->m_sName,ma->m_iOffset+1,((CAtom*)g_oaAtoms[m_baAtomIndex[ma->m_iType]])->m_pElement->m_fMass,i,ma->m_fAtomCode);
4797
 
        }
4798
 
 
4799
 
        i = 0;
4800
 
        do {
4801
 
                c1 = CountDifferentAtomCodes();
4802
 
 
4803
 
                if (g_bVerbose)
4804
 
                        mprintf(WHITE,"\n  Cycle %d: %d different atom codes exist.\n\n",i+1,c1);
4805
 
 
4806
 
                for (z=0;z<m_oaMolAtoms.GetSize();z++)
4807
 
                {
4808
 
                        ma = (CMolAtom*)m_oaMolAtoms[z];
4809
 
                        ma->m_fTempAtomCode = ma->m_fAtomCode * 5.0;
4810
 
 
4811
 
                        for (z2=0;z2<ma->m_oaBonds.GetSize();z2++)
4812
 
                                ma->m_fTempAtomCode += ((CMolAtom*)ma->m_oaBonds[z2])->m_fAtomCode;
4813
 
                }
4814
 
                for (z=0;z<m_oaMolAtoms.GetSize();z++)
4815
 
                {
4816
 
                        ma = (CMolAtom*)m_oaMolAtoms[z];
4817
 
                        ma->m_fAtomCode = ma->m_fTempAtomCode;
4818
 
 
4819
 
                        if (g_bVerbose)
4820
 
                                mprintf("    Atom %d (%s%d): %.2f\n",z+1,((CAtom*)g_oaAtoms[m_baAtomIndex[ma->m_iType]])->m_sName,ma->m_iOffset+1,ma->m_fAtomCode);
4821
 
                }
4822
 
                c2 = CountDifferentAtomCodes();
4823
 
                i++;
4824
 
//              mprintf("Iteration %d: %d classes before, %d classes after.\n",i,c1,c2);
4825
 
        } while (c1 != c2);
4826
 
 
4827
 
        if (g_bVerbose)
4828
 
                mprintf(WHITE,"\nSorting...\n");
4829
 
 
4830
 
        m_iAtomClasses = c2;
4831
 
//      mprintf("Finished.\n");
4832
 
//      mprintf("%d Iterations, %d atom classes found.\n",i,c2);
4833
 
//      mprintf("Sorting Atom Codes...");
4834
 
 
4835
 
        // Sortieren mittels StackSort
4836
 
        for (z=0;z<m_oaMolAtoms.GetSize();z++)
4837
 
        {
4838
 
                ac = -1;
4839
 
                i = -1;
4840
 
                for (z2=z;z2<m_oaMolAtoms.GetSize();z2++)
4841
 
                {
4842
 
                        if (((CMolAtom*)m_oaMolAtoms[z2])->m_fAtomCode > ac)
4843
 
                        {
4844
 
                                ac = ((CMolAtom*)m_oaMolAtoms[z2])->m_fAtomCode;
4845
 
                                i = z2;
4846
 
                        }
4847
 
                }
4848
 
                if (i != -1)
4849
 
                {
4850
 
                        ma = (CMolAtom*)m_oaMolAtoms[z];
4851
 
                        m_oaMolAtoms[z] = m_oaMolAtoms[i];
4852
 
                        m_oaMolAtoms[i] = ma;
4853
 
                        ((CMolAtom*)m_oaMolAtoms[z])->m_iMolAtomNumber = z;
4854
 
                } else
4855
 
                {
4856
 
                        eprintf("CSingleMolecule::BuildAtomCodes(): Weird error.\n");
4857
 
                        return;
4858
 
                }
4859
 
        }
4860
 
 
4861
 
        if (g_bVerbose)
4862
 
        {
4863
 
                for (z=0;z<m_oaMolAtoms.GetSize();z++)
4864
 
                {
4865
 
                        ma = (CMolAtom*)m_oaMolAtoms[z];
4866
 
                        mprintf("    Atom %d (%s%d): %.2f\n",z+1,((CAtom*)g_oaAtoms[m_baAtomIndex[ma->m_iType]])->m_sName,ma->m_iOffset+1,ma->m_fAtomCode);
4867
 
                }
4868
 
                mprintf(WHITE,"Finished.\n\n");
4869
 
        }
4870
 
//      mprintf("Finished.\n");
4871
 
}
4872
 
 
4873
 
 
4874
 
int CSingleMolecule::CountDifferentAtomCodes()
4875
 
{
4876
 
        int z, z2, i;
4877
 
        double *d;
4878
 
 
4879
 
        try { d = new double[m_oaMolAtoms.GetSize()]; } catch(...) { d = NULL; }
4880
 
        if (d == NULL) NewException((double)m_oaMolAtoms.GetSize()*sizeof(double),__FILE__,__LINE__,__PRETTY_FUNCTION__);
4881
 
        
4882
 
        i = 0;
4883
 
        for (z=0;z<m_oaMolAtoms.GetSize();z++)
4884
 
        {
4885
 
                for (z2=0;z2<i;z2++)
4886
 
                        if (d[z2] == ((CMolAtom*)m_oaMolAtoms[z])->m_fAtomCode)
4887
 
                                goto _next;
4888
 
                d[i] = ((CMolAtom*)m_oaMolAtoms[z])->m_fAtomCode;
4889
 
                i++;
4890
 
_next:;
4891
 
        }
4892
 
        delete[] d;
4893
 
        return i;
4894
 
}
4895
 
 
4896
 
 
4897
 
void CMSD::Parse()
4898
 
{
4899
 
        char buf[256];
4900
 
        int ti;
4901
 
//      float tf;
4902
 
 
4903
 
        BTIN;
4904
 
 
4905
 
        try { m_pMSD = new CAF(); } catch(...) { m_pMSD = NULL; }
4906
 
        if (m_pMSD == NULL) NewException((double)sizeof(CAF),__FILE__,__LINE__,__PRETTY_FUNCTION__);
4907
 
        
4908
 
        mprintf(WHITE,"\n*** Mean Square Displacement\n\n");
4909
 
 
4910
 
        try { m_pAtomGroup = new CAtomGroup(); } catch(...) { m_pAtomGroup = NULL; }
4911
 
        if (m_pAtomGroup == NULL) NewException((double)sizeof(CAtomGroup),__FILE__,__LINE__,__PRETTY_FUNCTION__);
4912
 
        
4913
 
_rdfatom1:
4914
 
        mprintf("    Which atom(s) to take from OM %s (e.g. \"C1,C3-5,H\", \"*\"=all)? [#2] ",((CMolecule*)g_oaMolecules[m_iShowMol])->m_sName);
4915
 
        inpprintf("! Which atom(s) to take from OM %s (e.g. \"C1,C3-5,H\", \"*\"=all)? [#2]\n",((CMolecule*)g_oaMolecules[m_iShowMol])->m_sName);
4916
 
        myget(buf);
4917
 
        if (strlen(buf) == 0)
4918
 
        {
4919
 
                if (!m_pAtomGroup->ParseAtoms((CMolecule*)g_oaMolecules[m_iShowMol],"#2"))
4920
 
                {
4921
 
                        eprintf("Weird error.\n");
4922
 
                        inpprintf("! Weird error.\n");
4923
 
                        goto _rdfatom1;
4924
 
                }
4925
 
        } else if (!m_pAtomGroup->ParseAtoms((CMolecule*)g_oaMolecules[m_iShowMol],buf))
4926
 
        {
4927
 
                eprintf("Wrong input.\n");
4928
 
                inpprintf("! Wrong input.\n");
4929
 
                goto _rdfatom1;
4930
 
        }
4931
 
 
4932
 
//_depth:
4933
 
        if (g_iTrajSteps != -1)
4934
 
                m_iResolution = AskUnsignedInteger("    Enter the resolution (=depth) for this MSD (in time steps): [%d] ",int(g_iTrajSteps*0.75),int(g_iTrajSteps*0.75));
4935
 
                        else m_iResolution = AskUnsignedInteger("    Enter the resolution (=depth) for this MSD (in time steps): [10000] ",10000);
4936
 
 
4937
 
        m_iShowAtoms = m_pAtomGroup->m_iAtomGes;
4938
 
 
4939
 
/*      if (g_iTrajSteps != -1)
4940
 
        {
4941
 
                if (g_bMSDCacheMode)
4942
 
                {
4943
 
                        tf = g_iTrajSteps*m_pAtomGroup->m_iAtomGes*((CMolecule*)g_oaMolecules[m_iShowMol])->m_laSingleMolIndex.GetSize()*3.0f*sizeof(float)/1024.0f/1024.0f;
4944
 
                        if (tf >= 10.0f)
4945
 
                                if (!AskYesNo("    This will occupy %.0f MB RAM (once, not for every MSD!). Continue (y/n)? [yes] ",true,tf))
4946
 
                                        goto _depth;
4947
 
                } else
4948
 
                {
4949
 
                        tf = m_iResolution*g_iGesVirtAtomCount*12.0f*sizeof(double)/1024.0f/1024.0f;
4950
 
                        if (tf >= 10.0f)
4951
 
                                if (!AskYesNo("    This will occupy %.0f MB RAM (once, not for every MSD!). Continue (y/n)? [yes] ",true,tf))
4952
 
                                        goto _depth;
4953
 
                }
4954
 
        }*/
4955
 
/*      if (m_iResolution > g_iMaxMSDDepth)
4956
 
                g_iMaxMSDDepth = m_iReolution;*/
4957
 
 
4958
 
        ti = m_iResolution / 1000;
4959
 
        if (ti < 1)
4960
 
                ti = 1;
4961
 
        m_iStride = AskUnsignedInteger("    Take every n-th step for the time axis of the MSD: [%d] ",ti,ti);
4962
 
        m_iStride2 = AskUnsignedInteger("    Shift correlation window n time steps at once: [%d] ",m_iStride,m_iStride);
4963
 
 
4964
 
        if (g_bAdvanced2)
4965
 
        {
4966
 
                m_bSplit = AskYesNo("    Decompose this MSD into contributions from each individual molecule (y/n)? [no] ",false);
4967
 
                if (AskYesNo("    Take into account only certain dimensions for displacement (y/n)? [no] ",false))
4968
 
                {
4969
 
                        m_bTakeX = AskYesNo("      Take into account contributions along X axis (y/n)? [yes] ",true);
4970
 
                        m_bTakeY = AskYesNo("      Take into account contributions along X axis (y/n)? [yes] ",true);
4971
 
                        m_bTakeZ = AskYesNo("      Take into account contributions along X axis (y/n)? [yes] ",true);
4972
 
                } else
4973
 
                {
4974
 
                        m_bTakeX = true;
4975
 
                        m_bTakeY = true;
4976
 
                        m_bTakeZ = true;
4977
 
                }
4978
 
        } else
4979
 
        {
4980
 
                m_bSplit = false;
4981
 
                m_bTakeX = true;
4982
 
                m_bTakeY = true;
4983
 
                m_bTakeZ = true;
4984
 
        }
4985
 
 
4986
 
        BuildName();
4987
 
        BTOUT;
4988
 
}
4989
 
 
4990
 
 
4991
 
void CMSD::BuildName()
4992
 
{
4993
 
        BTIN;
4994
 
        char tmp[256];
4995
 
 
4996
 
        sprintf(tmp,"%s_%s",((CMolecule*)g_oaMolecules[m_iShowMol])->m_sName,m_pAtomGroup->m_sName);
4997
 
 
4998
 
        if ((!m_bTakeX) || (!m_bTakeY) || (!m_bTakeZ))
4999
 
        {
5000
 
                strcat(tmp,"_");
5001
 
                if (m_bTakeX)
5002
 
                        strcat(tmp,"X");
5003
 
                if (m_bTakeY)
5004
 
                        strcat(tmp,"Y");
5005
 
                if (m_bTakeZ)
5006
 
                        strcat(tmp,"Z");
5007
 
        }
5008
 
 
5009
 
        try { m_sName = new char[strlen(tmp)+1]; } catch(...) { m_sName = NULL; }
5010
 
        if (m_sName == NULL) NewException((double)(strlen(tmp)+1)*sizeof(char),__FILE__,__LINE__,__PRETTY_FUNCTION__);
5011
 
        
5012
 
        strcpy(m_sName,tmp);
5013
 
        BTOUT;
5014
 
}
5015
 
 
5016
 
 
5017
 
void CVHDF::CorrectCount()
5018
 
{
5019
 
        int x, y;
5020
 
 
5021
 
        for (y=0;y<m_iResolution;y++)
5022
 
                for (x=0;x<m_iDepth/m_iStride;x++)
5023
 
                        if (m_pCount[x] != 0)
5024
 
                                m_pVHDF->m_pBin[y*m_iDepth/m_iStride+x] /= m_pCount[x];
5025
 
}
5026
 
 
5027
 
 
5028
 
void CConditionSubGroup::PrintData()
5029
 
{
5030
 
        int z;
5031
 
        double d;
5032
 
 
5033
 
        mprintf(GREEN,"\n*** Data for %d. set of conditions ***\n\n",m_iNumber+1);
5034
 
        mprintf("    %.0f of %.0f molecules passed this set of conditions (%.4f percent).\n",m_fPassed,m_fTotal,ZeroDivide(m_fPassed,m_fTotal)*100.0f);
5035
 
        d = 1.0;
5036
 
        for (z=0;z<m_oaConditions.GetSize();z++)
5037
 
        {
5038
 
                mprintf("      - Condition %d: %.0f of %.0f molecules passed (%.4f percent).\n",z+1,((CNbSearch*)m_oaConditions[z])->m_fMoleculesPassed,((CNbSearch*)m_oaConditions[z])->m_fMoleculesTotal,ZeroDivide(((CNbSearch*)m_oaConditions[z])->m_fMoleculesPassed,((CNbSearch*)m_oaConditions[z])->m_fMoleculesTotal)*100.0);
5039
 
                d *= ZeroDivide(((CNbSearch*)m_oaConditions[z])->m_fMoleculesPassed,((CNbSearch*)m_oaConditions[z])->m_fMoleculesTotal);
5040
 
        }
5041
 
        mprintf("\n");
5042
 
        if (m_oaConditions.GetSize() > 1)
5043
 
        {
5044
 
                mprintf("    The product of the condition probabilities is %.4f percent.\n",d*100.0);
5045
 
                mprintf("    If the conditions would be uncorrelated, this would be also the probability for the set.\n");
5046
 
                mprintf("    Therefore, the conditions are %s correlated for %.4f percent.\n\n",(d<ZeroDivide(m_fPassed,m_fTotal))?"positively":"negatively",(d<ZeroDivide(m_fPassed,m_fTotal))?(ZeroDivide(ZeroDivide(m_fPassed,m_fTotal),d)-1.0)*100.0:(ZeroDivide(d,ZeroDivide(m_fPassed,m_fTotal))-1.0)*100.0);
5047
 
        }
5048
 
 
5049
 
        for (z=0;z<m_oaConditions.GetSize();z++)
5050
 
                ((CNbSearch*)m_oaConditions[z])->PrintTable();
5051
 
}
5052
 
 
5053
 
 
5054
 
void CConditionSubGroup::PrintData(FILE *a)
5055
 
{
5056
 
        int z;
5057
 
 
5058
 
        mfprintf(a,"\n*** Data for %d. set of conditions ***\n\n",m_iNumber+1);
5059
 
        mfprintf(a,"    %.0f of %.0f molecules passed this set of conditions (%.4f percent).\n",m_fPassed,m_fTotal,ZeroDivide(m_fPassed,m_fTotal)*100.0f);
5060
 
        for (z=0;z<m_oaConditions.GetSize();z++)
5061
 
                ((CNbSearch*)m_oaConditions[z])->PrintTable(a);
5062
 
}
5063
 
 
5064
 
 
5065
 
void CConditionSubGroup::PrintSingle(int om)
5066
 
{
5067
 
        int z;
5068
 
 
5069
 
        for (z=0;z<m_oaConditions.GetSize();z++)
5070
 
                ((CNbSearch*)m_oaConditions[z])->PrintSingle(om);
5071
 
}
5072
 
 
5073
 
 
5074
 
void CConditionGroup::PrintSingle(int om)
5075
 
{
5076
 
        int z;
5077
 
 
5078
 
        for (z=0;z<m_oaConditionSubGroups.GetSize();z++)
5079
 
                ((CConditionSubGroup*)m_oaConditionSubGroups[z])->PrintSingle(om);
5080
 
}
5081
 
 
5082
 
 
5083
 
void CConditionGroup::PrintTable()
5084
 
{
5085
 
        int z, z2;
5086
 
        double tf1, tf2, tf3;
5087
 
 
5088
 
        mprintf(WHITE,"*** Condition Table ***\n\n");
5089
 
        mprintf("    The rows indicate how many subconditions of condition 1 are fulfilled.\n");
5090
 
        mprintf("    The columns indicate how many subconditions of condition 2 are fulfilled.\n\n");
5091
 
 
5092
 
        mprintf("     ");
5093
 
        for (z=0;z<((CConditionSubGroup*)m_oaConditionSubGroups[1])->m_iCombinations+1;z++)
5094
 
                mprintf("| %4d    ",z);
5095
 
        mprintf("\n");
5096
 
        mprintf("-----");
5097
 
        for (z=0;z<((CConditionSubGroup*)m_oaConditionSubGroups[1])->m_iCombinations+1;z++)
5098
 
                mprintf("|---------",z);
5099
 
        mprintf("\n");
5100
 
        tf1 = 0;
5101
 
        tf2 = 0;
5102
 
        tf3 = 0;
5103
 
        for (z=0;z<((CConditionSubGroup*)m_oaConditionSubGroups[0])->m_iCombinations+1;z++)
5104
 
        {
5105
 
                mprintf(" %3d ",z);
5106
 
                for (z2=0;z2<((CConditionSubGroup*)m_oaConditionSubGroups[1])->m_iCombinations+1;z2++)
5107
 
                {
5108
 
                        if ((z > 0) && (z2 == 0))
5109
 
                                tf1 += m_pTable[z*(((CConditionSubGroup*)m_oaConditionSubGroups[1])->m_iCombinations+1)+z2];
5110
 
                        if ((z == 0) && (z2 > 0))
5111
 
                                tf2 += m_pTable[z*(((CConditionSubGroup*)m_oaConditionSubGroups[1])->m_iCombinations+1)+z2];
5112
 
                        if ((z > 0) && (z2 > 0))
5113
 
                                tf3 += m_pTable[z*(((CConditionSubGroup*)m_oaConditionSubGroups[1])->m_iCombinations+1)+z2];
5114
 
                        mprintf("| %7.3f ",m_pTable[z*(((CConditionSubGroup*)m_oaConditionSubGroups[1])->m_iCombinations+1)+z2]/m_fTableGes*100.0);
5115
 
                }
5116
 
                mprintf("\n");
5117
 
        }
5118
 
        mprintf("\n");
5119
 
        mprintf("    A RM/OM pair fulfills no condition:      %7.3f percent of the time.\n",m_pTable[0]/m_fTableGes*100.0);
5120
 
        mprintf("    A RM/OM pair fulfills only condition 1:  %7.3f percent of the time.\n",tf1/m_fTableGes*100.0);
5121
 
        mprintf("    A RM/OM pair fulfills only condition 2:  %7.3f percent of the time.\n",tf2/m_fTableGes*100.0);
5122
 
        mprintf("    A RM/OM pair fulfills both conditions:   %7.3f percent of the time.\n",tf3/m_fTableGes*100.0);
5123
 
        mprintf("                                    Total:   %7.3f percent of the time.\n",100.0);
5124
 
        mprintf("\n");
5125
 
        mprintf(WHITE,"*** Condition Table End ***\n\n");
5126
 
}
5127
 
 
5128
 
 
5129
 
void CObservation::ListCDFObservations(int z)
5130
 
{
5131
 
        int z2, ti, ti2, ti3;
5132
 
        CxIntArray tempwa;
5133
 
 
5134
 
        switch(g_iObsChannel[z])
5135
 
        {
5136
 
                case 0: // RDF
5137
 
                        if (m_bOthers)
5138
 
                        {
5139
 
                                if (m_bSecondShowMol && (z == 1))
5140
 
                                        m_pRDF[z]->BuildAtomList((CSingleMolecule*)g_oaSingleMolecules[((CMolecule*)g_oaMolecules[g_iFixMol])->m_laSingleMolIndex[0]],(CSingleMolecule*)g_oaSingleMolecules[((CMolecule*)g_oaMolecules[m_iShowMol2])->m_laSingleMolIndex[0]],&tempwa);
5141
 
                                                else m_pRDF[z]->BuildAtomList((CSingleMolecule*)g_oaSingleMolecules[((CMolecule*)g_oaMolecules[g_iFixMol])->m_laSingleMolIndex[0]],(CSingleMolecule*)g_oaSingleMolecules[((CMolecule*)g_oaMolecules[m_iShowMol])->m_laSingleMolIndex[0]],&tempwa);
5142
 
                        } else m_pRDF[z]->BuildAtomList((CSingleMolecule*)g_oaSingleMolecules[((CMolecule*)g_oaMolecules[g_iFixMol])->m_laSingleMolIndex[0]],(CSingleMolecule*)g_oaSingleMolecules[((CMolecule*)g_oaMolecules[g_iFixMol])->m_laSingleMolIndex[0]],&tempwa);
5143
 
                        for (z2=0;z2<tempwa.GetSize()/2;z2++)
5144
 
                        {
5145
 
                                ti = tempwa[z2*2];
5146
 
                                ti2 = tempwa[z2*2+1];
5147
 
                                mprintf("  * %2d.) Distance %s%d (%s) <--> %s%d (%s)\n",z2+1,((CAtom*)g_oaAtoms[g_waAtomRealElement[ti]])->m_sName,g_waAtomMolNumber[ti]+1,((CMolecule*)g_oaMolecules[g_waAtomMolIndex[ti]])->m_sName,((CAtom*)g_oaAtoms[g_waAtomRealElement[ti2]])->m_sName,g_waAtomMolNumber[ti2]+1,((CMolecule*)g_oaMolecules[g_waAtomMolIndex[ti2]])->m_sName);
5148
 
                        }
5149
 
                        break;
5150
 
 
5151
 
                case 1: // ADF
5152
 
                        if (m_bOthers)
5153
 
                        {
5154
 
                                if (m_bSecondShowMol && (z == 1))
5155
 
                                        m_pADF[z]->BuildAtomList((CSingleMolecule*)g_oaSingleMolecules[((CMolecule*)g_oaMolecules[g_iFixMol])->m_laSingleMolIndex[0]],(CSingleMolecule*)g_oaSingleMolecules[((CMolecule*)g_oaMolecules[m_iShowMol2])->m_laSingleMolIndex[0]],&tempwa);
5156
 
                                                else m_pADF[z]->BuildAtomList((CSingleMolecule*)g_oaSingleMolecules[((CMolecule*)g_oaMolecules[g_iFixMol])->m_laSingleMolIndex[0]],(CSingleMolecule*)g_oaSingleMolecules[((CMolecule*)g_oaMolecules[m_iShowMol])->m_laSingleMolIndex[0]],&tempwa);
5157
 
                        } else m_pADF[z]->BuildAtomList((CSingleMolecule*)g_oaSingleMolecules[((CMolecule*)g_oaMolecules[g_iFixMol])->m_laSingleMolIndex[0]],(CSingleMolecule*)g_oaSingleMolecules[((CMolecule*)g_oaMolecules[g_iFixMol])->m_laSingleMolIndex[0]],&tempwa);
5158
 
                        for (z2=0;z2<tempwa.GetSize()/6;z2++)
5159
 
                        {
5160
 
                                mprintf("  * %2d.) Angle ",z2+1);
5161
 
                                if (m_pADF[z]->m_bOrtho[0])
5162
 
                                {
5163
 
                                        ti = tempwa[z2*6];
5164
 
                                        ti2 = tempwa[z2*6+1];
5165
 
                                        ti3 = tempwa[z2*6+2];
5166
 
                                        mprintf("[%s%d (%s), %s%d (%s), %s%d (%s)] to ",((CAtom*)g_oaAtoms[g_waAtomRealElement[ti]])->m_sName,g_waAtomMolNumber[ti]+1,((CMolecule*)g_oaMolecules[g_waAtomMolIndex[ti]])->m_sName,((CAtom*)g_oaAtoms[g_waAtomRealElement[ti2]])->m_sName,g_waAtomMolNumber[ti2]+1,((CMolecule*)g_oaMolecules[g_waAtomMolIndex[ti2]])->m_sName,((CAtom*)g_oaAtoms[g_waAtomRealElement[ti3]])->m_sName,g_waAtomMolNumber[ti3]+1,((CMolecule*)g_oaMolecules[g_waAtomMolIndex[ti3]])->m_sName);
5167
 
                                } else
5168
 
                                {
5169
 
                                        ti = tempwa[z2*6];
5170
 
                                        ti2 = tempwa[z2*6+1];
5171
 
                                        mprintf("[%s%d (%s) --> %s%d (%s)] to ",((CAtom*)g_oaAtoms[g_waAtomRealElement[ti]])->m_sName,g_waAtomMolNumber[ti]+1,((CMolecule*)g_oaMolecules[g_waAtomMolIndex[ti]])->m_sName,((CAtom*)g_oaAtoms[g_waAtomRealElement[ti2]])->m_sName,g_waAtomMolNumber[ti2]+1,((CMolecule*)g_oaMolecules[g_waAtomMolIndex[ti2]])->m_sName);
5172
 
                                }
5173
 
                                if (m_pADF[z]->m_bOrtho[1])
5174
 
                                {
5175
 
                                        ti = tempwa[z2*6+3];
5176
 
                                        ti2 = tempwa[z2*6+4];
5177
 
                                        ti3 = tempwa[z2*6+5];
5178
 
                                        mprintf("[%s%d (%s), %s%d (%s), %s%d (%s)]\n",((CAtom*)g_oaAtoms[g_waAtomRealElement[ti]])->m_sName,g_waAtomMolNumber[ti]+1,((CMolecule*)g_oaMolecules[g_waAtomMolIndex[ti]])->m_sName,((CAtom*)g_oaAtoms[g_waAtomRealElement[ti2]])->m_sName,g_waAtomMolNumber[ti2]+1,((CMolecule*)g_oaMolecules[g_waAtomMolIndex[ti2]])->m_sName,((CAtom*)g_oaAtoms[g_waAtomRealElement[ti3]])->m_sName,g_waAtomMolNumber[ti3]+1,((CMolecule*)g_oaMolecules[g_waAtomMolIndex[ti3]])->m_sName);
5179
 
                                } else
5180
 
                                {
5181
 
                                        ti = tempwa[z2*6+3];
5182
 
                                        ti2 = tempwa[z2*6+4];
5183
 
                                        mprintf("[%s%d (%s) --> %s%d (%s)]\n",((CAtom*)g_oaAtoms[g_waAtomRealElement[ti]])->m_sName,g_waAtomMolNumber[ti]+1,((CMolecule*)g_oaMolecules[g_waAtomMolIndex[ti]])->m_sName,((CAtom*)g_oaAtoms[g_waAtomRealElement[ti2]])->m_sName,g_waAtomMolNumber[ti2]+1,((CMolecule*)g_oaMolecules[g_waAtomMolIndex[ti2]])->m_sName);
5184
 
                                }
5185
 
                        }
5186
 
                        break;
5187
 
 
5188
 
                case 2: // DDF
5189
 
                        if (m_bOthers)
5190
 
                        {
5191
 
                                if (m_bSecondShowMol && (z == 1))
5192
 
                                        m_pDDF[z]->BuildAtomList((CSingleMolecule*)g_oaSingleMolecules[((CMolecule*)g_oaMolecules[g_iFixMol])->m_laSingleMolIndex[0]],(CSingleMolecule*)g_oaSingleMolecules[((CMolecule*)g_oaMolecules[m_iShowMol2])->m_laSingleMolIndex[0]],&tempwa);
5193
 
                                                else m_pDDF[z]->BuildAtomList((CSingleMolecule*)g_oaSingleMolecules[((CMolecule*)g_oaMolecules[g_iFixMol])->m_laSingleMolIndex[0]],(CSingleMolecule*)g_oaSingleMolecules[((CMolecule*)g_oaMolecules[m_iShowMol])->m_laSingleMolIndex[0]],&tempwa);
5194
 
                        } else m_pDDF[z]->BuildAtomList((CSingleMolecule*)g_oaSingleMolecules[((CMolecule*)g_oaMolecules[g_iFixMol])->m_laSingleMolIndex[0]],(CSingleMolecule*)g_oaSingleMolecules[((CMolecule*)g_oaMolecules[g_iFixMol])->m_laSingleMolIndex[0]],&tempwa);
5195
 
                        for (z2=0;z2<tempwa.GetSize()/9;z2++)
5196
 
                        {
5197
 
                                mprintf("  * %2d.) Dihedral Angle ",z2+1);
5198
 
                                if (m_pDDF[z]->m_bOrtho[0])
5199
 
                                {
5200
 
                                        ti = tempwa[z2*9];
5201
 
                                        ti2 = tempwa[z2*9+1];
5202
 
                                        ti3 = tempwa[z2*9+2];
5203
 
                                        mprintf("[%s%d (%s), %s%d (%s), %s%d (%s)] - ",((CAtom*)g_oaAtoms[g_waAtomRealElement[ti]])->m_sName,g_waAtomMolNumber[ti]+1,((CMolecule*)g_oaMolecules[g_waAtomMolIndex[ti]])->m_sName,((CAtom*)g_oaAtoms[g_waAtomRealElement[ti2]])->m_sName,g_waAtomMolNumber[ti2]+1,((CMolecule*)g_oaMolecules[g_waAtomMolIndex[ti2]])->m_sName,((CAtom*)g_oaAtoms[g_waAtomRealElement[ti3]])->m_sName,g_waAtomMolNumber[ti3]+1,((CMolecule*)g_oaMolecules[g_waAtomMolIndex[ti3]])->m_sName);
5204
 
                                } else
5205
 
                                {
5206
 
                                        ti = tempwa[z2*9];
5207
 
                                        ti2 = tempwa[z2*9+1];
5208
 
                                        mprintf("[%s%d (%s) --> %s%d (%s)] - ",((CAtom*)g_oaAtoms[g_waAtomRealElement[ti]])->m_sName,g_waAtomMolNumber[ti]+1,((CMolecule*)g_oaMolecules[g_waAtomMolIndex[ti]])->m_sName,((CAtom*)g_oaAtoms[g_waAtomRealElement[ti2]])->m_sName,g_waAtomMolNumber[ti2]+1,((CMolecule*)g_oaMolecules[g_waAtomMolIndex[ti2]])->m_sName);
5209
 
                                }
5210
 
                                if (m_pDDF[z]->m_bOrtho[1])
5211
 
                                {
5212
 
                                        ti = tempwa[z2*9+3];
5213
 
                                        ti2 = tempwa[z2*9+4];
5214
 
                                        ti3 = tempwa[z2*9+5];
5215
 
                                        mprintf("[%s%d (%s), %s%d (%s), %s%d (%s)] - ",((CAtom*)g_oaAtoms[g_waAtomRealElement[ti]])->m_sName,g_waAtomMolNumber[ti]+1,((CMolecule*)g_oaMolecules[g_waAtomMolIndex[ti]])->m_sName,((CAtom*)g_oaAtoms[g_waAtomRealElement[ti2]])->m_sName,g_waAtomMolNumber[ti2]+1,((CMolecule*)g_oaMolecules[g_waAtomMolIndex[ti2]])->m_sName,((CAtom*)g_oaAtoms[g_waAtomRealElement[ti3]])->m_sName,g_waAtomMolNumber[ti3]+1,((CMolecule*)g_oaMolecules[g_waAtomMolIndex[ti3]])->m_sName);
5216
 
                                } else
5217
 
                                {
5218
 
                                        ti = tempwa[z2*9+3];
5219
 
                                        ti2 = tempwa[z2*9+4];
5220
 
                                        mprintf("[%s%d (%s) --> %s%d (%s)] - ",((CAtom*)g_oaAtoms[g_waAtomRealElement[ti]])->m_sName,g_waAtomMolNumber[ti]+1,((CMolecule*)g_oaMolecules[g_waAtomMolIndex[ti]])->m_sName,((CAtom*)g_oaAtoms[g_waAtomRealElement[ti2]])->m_sName,g_waAtomMolNumber[ti2]+1,((CMolecule*)g_oaMolecules[g_waAtomMolIndex[ti2]])->m_sName);
5221
 
                                }
5222
 
                                if (m_pDDF[z]->m_bOrtho[2])
5223
 
                                {
5224
 
                                        ti = tempwa[z2*9+6];
5225
 
                                        ti2 = tempwa[z2*9+7];
5226
 
                                        ti3 = tempwa[z2*9+8];
5227
 
                                        mprintf("[%s%d (%s), %s%d (%s), %s%d (%s)]\n",((CAtom*)g_oaAtoms[g_waAtomRealElement[ti]])->m_sName,g_waAtomMolNumber[ti]+1,((CMolecule*)g_oaMolecules[g_waAtomMolIndex[ti]])->m_sName,((CAtom*)g_oaAtoms[g_waAtomRealElement[ti2]])->m_sName,g_waAtomMolNumber[ti2]+1,((CMolecule*)g_oaMolecules[g_waAtomMolIndex[ti2]])->m_sName,((CAtom*)g_oaAtoms[g_waAtomRealElement[ti3]])->m_sName,g_waAtomMolNumber[ti3]+1,((CMolecule*)g_oaMolecules[g_waAtomMolIndex[ti3]])->m_sName);
5228
 
                                } else
5229
 
                                {
5230
 
                                        ti = tempwa[z2*9+6];
5231
 
                                        ti2 = tempwa[z2*9+7];
5232
 
                                        mprintf("[%s%d (%s) --> %s%d (%s)]\n",((CAtom*)g_oaAtoms[g_waAtomRealElement[ti]])->m_sName,g_waAtomMolNumber[ti]+1,((CMolecule*)g_oaMolecules[g_waAtomMolIndex[ti]])->m_sName,((CAtom*)g_oaAtoms[g_waAtomRealElement[ti2]])->m_sName,g_waAtomMolNumber[ti2]+1,((CMolecule*)g_oaMolecules[g_waAtomMolIndex[ti2]])->m_sName);
5233
 
                                }
5234
 
                        }
5235
 
                        break;
5236
 
 
5237
 
                case 3:
5238
 
                        eprintf("(not implemented)\n");
5239
 
                        break;
5240
 
 
5241
 
                case 4:
5242
 
                        eprintf("(not implemented)\n");
5243
 
                        break;
5244
 
 
5245
 
                case 5: // PlDF
5246
 
                        if (m_bOthers)
5247
 
                        {
5248
 
                                if (m_bSecondShowMol && (z == 1))
5249
 
                                        m_pPlDF[z]->BuildAtomList((CSingleMolecule*)g_oaSingleMolecules[((CMolecule*)g_oaMolecules[g_iFixMol])->m_laSingleMolIndex[0]],(CSingleMolecule*)g_oaSingleMolecules[((CMolecule*)g_oaMolecules[m_iShowMol2])->m_laSingleMolIndex[0]],&tempwa);
5250
 
                                                else m_pPlDF[z]->BuildAtomList((CSingleMolecule*)g_oaSingleMolecules[((CMolecule*)g_oaMolecules[g_iFixMol])->m_laSingleMolIndex[0]],(CSingleMolecule*)g_oaSingleMolecules[((CMolecule*)g_oaMolecules[m_iShowMol])->m_laSingleMolIndex[0]],&tempwa);
5251
 
                        } else m_pPlDF[z]->BuildAtomList((CSingleMolecule*)g_oaSingleMolecules[((CMolecule*)g_oaMolecules[g_iFixMol])->m_laSingleMolIndex[0]],(CSingleMolecule*)g_oaSingleMolecules[((CMolecule*)g_oaMolecules[g_iFixMol])->m_laSingleMolIndex[0]],&tempwa);
5252
 
                        for (z2=0;z2<tempwa.GetSize()/4;z2++)
5253
 
                        {
5254
 
                                mprintf("  * %2d.) Distance from Plane ",z2+1);
5255
 
                                if (m_pPlDF[z]->m_bNormal)
5256
 
                                {
5257
 
                                        ti = tempwa[z2*4];
5258
 
                                        ti2 = tempwa[z2*4+1];
5259
 
                                        mprintf("[%s%d (%s) --> %s%d (%s)] - ",((CAtom*)g_oaAtoms[g_waAtomRealElement[ti]])->m_sName,g_waAtomMolNumber[ti]+1,((CMolecule*)g_oaMolecules[g_waAtomMolIndex[ti]])->m_sName,((CAtom*)g_oaAtoms[g_waAtomRealElement[ti2]])->m_sName,g_waAtomMolNumber[ti2]+1,((CMolecule*)g_oaMolecules[g_waAtomMolIndex[ti2]])->m_sName);
5260
 
                                } else
5261
 
                                {
5262
 
                                        ti = tempwa[z2*4];
5263
 
                                        ti2 = tempwa[z2*4+1];
5264
 
                                        ti3 = tempwa[z2*4+2];
5265
 
                                        mprintf("[%s%d (%s), %s%d (%s), %s%d (%s)] - ",((CAtom*)g_oaAtoms[g_waAtomRealElement[ti]])->m_sName,g_waAtomMolNumber[ti]+1,((CMolecule*)g_oaMolecules[g_waAtomMolIndex[ti]])->m_sName,((CAtom*)g_oaAtoms[g_waAtomRealElement[ti2]])->m_sName,g_waAtomMolNumber[ti2]+1,((CMolecule*)g_oaMolecules[g_waAtomMolIndex[ti2]])->m_sName,((CAtom*)g_oaAtoms[g_waAtomRealElement[ti3]])->m_sName,g_waAtomMolNumber[ti3]+1,((CMolecule*)g_oaMolecules[g_waAtomMolIndex[ti3]])->m_sName);
5266
 
                                }
5267
 
                                ti = tempwa[z2*4+3];
5268
 
                                mprintf("%s%d (%s)\n",((CAtom*)g_oaAtoms[g_waAtomRealElement[ti]])->m_sName,g_waAtomMolNumber[ti]+1,((CMolecule*)g_oaMolecules[g_waAtomMolIndex[ti]])->m_sName);
5269
 
                        }
5270
 
                        break;
5271
 
 
5272
 
                case 6: // LiDF
5273
 
                        if (m_bOthers)
5274
 
                        {
5275
 
                                if (m_bSecondShowMol && (z == 1))
5276
 
                                        m_pLiDF[z]->BuildAtomList((CSingleMolecule*)g_oaSingleMolecules[((CMolecule*)g_oaMolecules[g_iFixMol])->m_laSingleMolIndex[0]],(CSingleMolecule*)g_oaSingleMolecules[((CMolecule*)g_oaMolecules[m_iShowMol2])->m_laSingleMolIndex[0]],&tempwa);
5277
 
                                                else m_pLiDF[z]->BuildAtomList((CSingleMolecule*)g_oaSingleMolecules[((CMolecule*)g_oaMolecules[g_iFixMol])->m_laSingleMolIndex[0]],(CSingleMolecule*)g_oaSingleMolecules[((CMolecule*)g_oaMolecules[m_iShowMol])->m_laSingleMolIndex[0]],&tempwa);
5278
 
                        } else m_pLiDF[z]->BuildAtomList((CSingleMolecule*)g_oaSingleMolecules[((CMolecule*)g_oaMolecules[g_iFixMol])->m_laSingleMolIndex[0]],(CSingleMolecule*)g_oaSingleMolecules[((CMolecule*)g_oaMolecules[g_iFixMol])->m_laSingleMolIndex[0]],&tempwa);
5279
 
                        for (z2=0;z2<tempwa.GetSize()/4;z2++)
5280
 
                        {
5281
 
                                mprintf("  * %2d.) Distance from Plane ",z2+1);
5282
 
                                if (m_pLiDF[z]->m_bNormal)
5283
 
                                {
5284
 
                                        ti = tempwa[z2*4];
5285
 
                                        ti2 = tempwa[z2*4+1];
5286
 
                                        ti3 = tempwa[z2*4+2];
5287
 
                                        mprintf("[%s%d (%s), %s%d (%s), %s%d (%s)] - ",((CAtom*)g_oaAtoms[g_waAtomRealElement[ti]])->m_sName,g_waAtomMolNumber[ti]+1,((CMolecule*)g_oaMolecules[g_waAtomMolIndex[ti]])->m_sName,((CAtom*)g_oaAtoms[g_waAtomRealElement[ti2]])->m_sName,g_waAtomMolNumber[ti2]+1,((CMolecule*)g_oaMolecules[g_waAtomMolIndex[ti2]])->m_sName,((CAtom*)g_oaAtoms[g_waAtomRealElement[ti3]])->m_sName,g_waAtomMolNumber[ti3]+1,((CMolecule*)g_oaMolecules[g_waAtomMolIndex[ti3]])->m_sName);
5288
 
                                } else
5289
 
                                {
5290
 
                                        ti = tempwa[z2*4];
5291
 
                                        ti2 = tempwa[z2*4+1];
5292
 
                                        mprintf("[%s%d (%s) --> %s%d (%s)] - ",((CAtom*)g_oaAtoms[g_waAtomRealElement[ti]])->m_sName,g_waAtomMolNumber[ti]+1,((CMolecule*)g_oaMolecules[g_waAtomMolIndex[ti]])->m_sName,((CAtom*)g_oaAtoms[g_waAtomRealElement[ti2]])->m_sName,g_waAtomMolNumber[ti2]+1,((CMolecule*)g_oaMolecules[g_waAtomMolIndex[ti2]])->m_sName);
5293
 
                                }
5294
 
                                ti = tempwa[z2*4+3];
5295
 
                                mprintf("%s%d (%s)\n",((CAtom*)g_oaAtoms[g_waAtomRealElement[ti]])->m_sName,g_waAtomMolNumber[ti]+1,((CMolecule*)g_oaMolecules[g_waAtomMolIndex[ti]])->m_sName);
5296
 
                        }
5297
 
                        break;
5298
 
        }
5299
 
}
5300
 
 
5301
 
 
5302
 
void CSDF::CreateCutPlane()
5303
 
{
5304
 
        int x, y;
5305
 
        CxVector3 vec;
5306
 
 
5307
 
        try { m_pCutPlane = new C2DF(); } catch(...) { m_pCutPlane = NULL; }
5308
 
        if (m_pCutPlane == NULL) NewException((double)sizeof(C2DF),__FILE__,__LINE__,__PRETTY_FUNCTION__);
5309
 
        
5310
 
        m_pCutPlane->m_fMinVal[0] = -m_fRadius;
5311
 
        m_pCutPlane->m_fMinVal[1] = -m_fRadius;
5312
 
        m_pCutPlane->m_fMaxVal[0] = m_fRadius;
5313
 
        m_pCutPlane->m_fMaxVal[1] = m_fRadius;
5314
 
        m_pCutPlane->m_iRes[0] = m_iCutPlaneResolution;
5315
 
        m_pCutPlane->m_iRes[1] = m_iCutPlaneResolution;
5316
 
        m_pCutPlane->SetLabelX("X [pm]");
5317
 
        m_pCutPlane->SetLabelY("Y [pm]");
5318
 
        m_pCutPlane->Create();
5319
 
 
5320
 
        vec[2] = 0;
5321
 
        for (y=0;y<m_iCutPlaneResolution;y++)
5322
 
        {
5323
 
                vec[1] = (float)(((y+0.5)/m_pCutPlane->m_iRes[1])*(m_pCutPlane->m_fMaxVal[1]-m_pCutPlane->m_fMinVal[1])+m_pCutPlane->m_fMinVal[1]);
5324
 
                for (x=0;x<m_iCutPlaneResolution;x++)
5325
 
                {
5326
 
                        vec[0] = (float)(((x+0.5)/m_pCutPlane->m_iRes[0])*(m_pCutPlane->m_fMaxVal[0]-m_pCutPlane->m_fMinVal[0])+m_pCutPlane->m_fMinVal[0]);
5327
 
                        m_pCutPlane->AddToBin(x,y,m_pSDF->GetValue(vec));
5328
 
                }
5329
 
        }
5330
 
        if (m_bCutPlaneShowAtoms)
5331
 
        {
5332
 
                m_pCutPlane->AddCircle(0,0,((CAtom*)g_oaAtoms[g_iFixRealAtomType[0]])->m_pElement->m_fRadius*0.75,((CAtom*)g_oaAtoms[g_iFixRealAtomType[0]])->m_pElement->m_iColorR/255.0,((CAtom*)g_oaAtoms[g_iFixRealAtomType[0]])->m_pElement->m_iColorG/255.0,((CAtom*)g_oaAtoms[g_iFixRealAtomType[0]])->m_pElement->m_iColorB/255.0);
5333
 
                m_pCutPlane->AddCircle(m_fAtom2PosX / m_fPosCounter,0,((CAtom*)g_oaAtoms[g_iFixRealAtomType[1]])->m_pElement->m_fRadius*0.75,((CAtom*)g_oaAtoms[g_iFixRealAtomType[1]])->m_pElement->m_iColorR/255.0,((CAtom*)g_oaAtoms[g_iFixRealAtomType[1]])->m_pElement->m_iColorG/255.0,((CAtom*)g_oaAtoms[g_iFixRealAtomType[1]])->m_pElement->m_iColorB/255.0);
5334
 
                m_pCutPlane->AddCircle(m_fAtom3PosX / m_fPosCounter,m_fAtom3PosY / m_fPosCounter,((CAtom*)g_oaAtoms[g_iFixRealAtomType[2]])->m_pElement->m_fRadius*0.75,((CAtom*)g_oaAtoms[g_iFixRealAtomType[2]])->m_pElement->m_iColorR/255.0,((CAtom*)g_oaAtoms[g_iFixRealAtomType[2]])->m_pElement->m_iColorG/255.0,((CAtom*)g_oaAtoms[g_iFixRealAtomType[2]])->m_pElement->m_iColorB/255.0);
5335
 
        }
5336
 
}
5337
 
 
5338
 
 
5339
 
void CConditionGroup::Reset()
5340
 
{
5341
 
        int z;
5342
 
 
5343
 
        for (z=0;z<m_oaConditionSubGroups.GetSize();z++)
5344
 
                ((CConditionSubGroup*)m_oaConditionSubGroups[z])->Reset();
5345
 
 
5346
 
        for (z=0;z<((CMolecule*)g_oaMolecules[m_iShowMol])->m_laSingleMolIndex.GetSize();z++)
5347
 
                m_iPassCounter[z] = 0;
5348
 
}
5349
 
 
5350
 
 
5351
 
void CConditionSubGroup::Reset()
5352
 
{
5353
 
        int z;
5354
 
 
5355
 
        for (z=0;z<m_oaConditions.GetSize();z++)
5356
 
                ((CNbSearch*)m_oaConditions[z])->Reset();
5357
 
}
5358
 
 
5359
 
 
5360
 
void CRDF::CopyFrom(CRDF *p)
5361
 
{
5362
 
        int z;
5363
 
        CAtomGroup *ag;
5364
 
 
5365
 
        m_bAdaptive = p->m_bAdaptive;
5366
 
        m_bRadialCorrect = p->m_bRadialCorrect;
5367
 
        m_bSelf = p->m_bSelf;
5368
 
        m_fMinDist = p->m_fMinDist;
5369
 
        m_fMaxDist = p->m_fMaxDist;
5370
 
        m_iCombinations = p->m_iCombinations;
5371
 
        m_iHistogramRes = p->m_iHistogramRes;
5372
 
        m_iRefAtomGes = p->m_iRefAtomGes;
5373
 
        m_iRefOrSec[0] = p->m_iRefOrSec[0];
5374
 
        m_iRefOrSec[1] = p->m_iRefOrSec[1];
5375
 
        m_iResolution = p->m_iResolution;
5376
 
        m_iShowAtomGes = p->m_iShowAtomGes;
5377
 
        m_iShowMol = p->m_iShowMol;
5378
 
 
5379
 
        if (p->m_sName != NULL)
5380
 
        {
5381
 
                try { m_sName = new char[strlen(p->m_sName)+1]; } catch(...) { m_sName = NULL; }
5382
 
                if (m_sName == NULL) NewException((double)(strlen(p->m_sName)+1)*sizeof(char),__FILE__,__LINE__,__PRETTY_FUNCTION__);
5383
 
                
5384
 
                strcpy(m_sName,p->m_sName);
5385
 
        } else m_sName = NULL;
5386
 
 
5387
 
        if (p->m_sShortName != NULL)
5388
 
        {
5389
 
                try { m_sShortName = new char[strlen(p->m_sShortName)+1]; } catch(...) { m_sShortName = NULL; }
5390
 
                if (m_sShortName == NULL) NewException((double)(strlen(p->m_sShortName)+1)*sizeof(char),__FILE__,__LINE__,__PRETTY_FUNCTION__);
5391
 
                
5392
 
                strcpy(m_sShortName,p->m_sShortName);
5393
 
        } else m_sShortName = NULL;
5394
 
 
5395
 
        if (p->m_baDataEnabled != NULL)
5396
 
        {
5397
 
                try { m_baDataEnabled = new CxByteArray[((CMolecule*)g_oaMolecules[m_iShowMol])->m_laSingleMolIndex.GetSize()]; } catch(...) { m_baDataEnabled = NULL; }
5398
 
                if (m_baDataEnabled == NULL) NewException((double)((CMolecule*)g_oaMolecules[m_iShowMol])->m_laSingleMolIndex.GetSize()*sizeof(CxByteArray),__FILE__,__LINE__,__PRETTY_FUNCTION__);
5399
 
                
5400
 
                for (z=0;z<((CMolecule*)g_oaMolecules[m_iShowMol])->m_laSingleMolIndex.GetSize();z++)
5401
 
                        m_baDataEnabled[z].CopyFrom(&p->m_baDataEnabled[z]);
5402
 
        }
5403
 
 
5404
 
        if (p->m_faData != NULL)
5405
 
        {
5406
 
                try { m_faData = new CxDoubleArray[((CMolecule*)g_oaMolecules[m_iShowMol])->m_laSingleMolIndex.GetSize()]; } catch(...) { m_faData = NULL; }
5407
 
                if (m_faData == NULL) NewException((double)((CMolecule*)g_oaMolecules[m_iShowMol])->m_laSingleMolIndex.GetSize()*sizeof(CxDoubleArray),__FILE__,__LINE__,__PRETTY_FUNCTION__);
5408
 
                
5409
 
                for (z=0;z<((CMolecule*)g_oaMolecules[m_iShowMol])->m_laSingleMolIndex.GetSize();z++)
5410
 
                        m_faData[z].CopyFrom(&p->m_faData[z]);
5411
 
        }
5412
 
 
5413
 
        for (z=0;z<p->m_oaVectors.GetSize();z++)
5414
 
        {
5415
 
                try { ag = new CAtomGroup(); } catch(...) { ag = NULL; }
5416
 
                if (ag == NULL) NewException((double)sizeof(CAtomGroup),__FILE__,__LINE__,__PRETTY_FUNCTION__);
5417
 
 
5418
 
                ag->CopyFrom((CAtomGroup*)p->m_oaVectors[z]);
5419
 
                m_oaVectors.Add(ag);
5420
 
        }
5421
 
 
5422
 
        m_faMinMaxDist.CopyFrom(&p->m_faMinMaxDist);
5423
 
 
5424
 
        if (p->m_pRDF != NULL)
5425
 
        {
5426
 
                try { m_pRDF = new CDF(); } catch(...) { m_pRDF = NULL; }
5427
 
                if (m_pRDF == NULL) NewException((double)sizeof(CDF),__FILE__,__LINE__,__PRETTY_FUNCTION__);
5428
 
                
5429
 
                m_pRDF->CopyFrom(p->m_pRDF);
5430
 
        }
5431
 
}
5432
 
 
5433
 
 
5434
 
void CADF::CopyFrom(CADF *p)
5435
 
{
5436
 
        int z, z2;
5437
 
        CAtomGroup *ag;
5438
 
 
5439
 
        m_bCosine = p->m_bCosine;
5440
 
        m_bFoldAngle = p->m_bFoldAngle;
5441
 
        m_bMirror = p->m_bMirror;
5442
 
        m_bOrtho[0] = p->m_bOrtho[0];
5443
 
        m_bOrtho[1] = p->m_bOrtho[1];
5444
 
        m_iVecType[0] = p->m_iVecType[0];
5445
 
        m_iVecType[1] = p->m_iVecType[1];
5446
 
        m_bSelf = p->m_bSelf;
5447
 
        m_bStat = p->m_bStat;
5448
 
        m_fMinAngle = p->m_fMinAngle;
5449
 
        m_fMaxAngle = p->m_fMaxAngle;
5450
 
        m_iCombinations = p->m_iCombinations;
5451
 
        m_iHistogramRes = p->m_iHistogramRes;
5452
 
        for (z=0;z<2;z++)
5453
 
                for (z2=0;z2<3;z2++)
5454
 
                        m_iRefOrSec[z][z2] = p->m_iRefOrSec[z][z2];
5455
 
        m_iResolution = p->m_iResolution;
5456
 
        m_iShowMol = p->m_iShowMol;
5457
 
 
5458
 
        if (p->m_sName != NULL)
5459
 
        {
5460
 
                try { m_sName = new char[strlen(p->m_sName)+1]; } catch(...) { m_sName = NULL; }
5461
 
                if (m_sName == NULL) NewException((double)(strlen(p->m_sName)+1)*sizeof(char),__FILE__,__LINE__,__PRETTY_FUNCTION__);
5462
 
                
5463
 
                strcpy(m_sName,p->m_sName);
5464
 
        } else m_sName = NULL;
5465
 
 
5466
 
        if (p->m_sShortName != NULL)
5467
 
        {
5468
 
                try { m_sShortName = new char[strlen(p->m_sShortName)+1]; } catch(...) { m_sShortName = NULL; }
5469
 
                if (m_sShortName == NULL) NewException((double)(strlen(p->m_sShortName)+1)*sizeof(char),__FILE__,__LINE__,__PRETTY_FUNCTION__);
5470
 
                
5471
 
                strcpy(m_sShortName,p->m_sShortName);
5472
 
        } else m_sShortName = NULL;
5473
 
 
5474
 
        if (p->m_baDataEnabled != NULL)
5475
 
        {
5476
 
                try { m_baDataEnabled = new CxByteArray[((CMolecule*)g_oaMolecules[m_iShowMol])->m_laSingleMolIndex.GetSize()]; } catch(...) { m_baDataEnabled = NULL; }
5477
 
                if (m_baDataEnabled == NULL) NewException((double)((CMolecule*)g_oaMolecules[m_iShowMol])->m_laSingleMolIndex.GetSize()*sizeof(CxByteArray),__FILE__,__LINE__,__PRETTY_FUNCTION__);
5478
 
                
5479
 
                for (z=0;z<((CMolecule*)g_oaMolecules[m_iShowMol])->m_laSingleMolIndex.GetSize();z++)
5480
 
                        m_baDataEnabled[z].CopyFrom(&p->m_baDataEnabled[z]);
5481
 
        }
5482
 
 
5483
 
        if (p->m_faData != NULL)
5484
 
        {
5485
 
                try { m_faData = new CxDoubleArray[((CMolecule*)g_oaMolecules[m_iShowMol])->m_laSingleMolIndex.GetSize()]; } catch(...) { m_faData = NULL; }
5486
 
                if (m_faData == NULL) NewException((double)((CMolecule*)g_oaMolecules[m_iShowMol])->m_laSingleMolIndex.GetSize()*sizeof(CxDoubleArray),__FILE__,__LINE__,__PRETTY_FUNCTION__);
5487
 
                
5488
 
                for (z=0;z<((CMolecule*)g_oaMolecules[m_iShowMol])->m_laSingleMolIndex.GetSize();z++)
5489
 
                        m_faData[z].CopyFrom(&p->m_faData[z]);
5490
 
        }
5491
 
 
5492
 
        for (z=0;z<p->m_oaVectors.GetSize();z++)
5493
 
        {
5494
 
                if (p->m_oaVectors[z] != NULL)
5495
 
                {
5496
 
                        try { ag = new CAtomGroup(); } catch(...) { ag = NULL; }
5497
 
                        if (ag == NULL) NewException((double)sizeof(CAtomGroup),__FILE__,__LINE__,__PRETTY_FUNCTION__);
5498
 
 
5499
 
                        ag->CopyFrom((CAtomGroup*)p->m_oaVectors[z]);
5500
 
                        m_oaVectors.Add(ag);
5501
 
                } else m_oaVectors.Add(NULL);
5502
 
        }
5503
 
 
5504
 
        m_faMinMaxAngle.CopyFrom(&p->m_faMinMaxAngle);
5505
 
 
5506
 
        if (p->m_pADF != NULL)
5507
 
        {
5508
 
                try { m_pADF = new CDF(); } catch(...) { m_pADF = NULL; }
5509
 
                if (m_pADF == NULL) NewException((double)sizeof(CDF),__FILE__,__LINE__,__PRETTY_FUNCTION__);
5510
 
                
5511
 
                m_pADF->CopyFrom(p->m_pADF);
5512
 
        }
5513
 
}
5514
 
 
5515
 
 
5516
 
void CConditionSubGroup::CopyFrom(CConditionSubGroup *p)
5517
 
{
5518
 
        int z;
5519
 
        CNbSearch *nb;
5520
 
 
5521
 
        m_fPassed = p->m_fPassed;
5522
 
        m_fTotal = p->m_fTotal;
5523
 
        m_iCombinations = p->m_iCombinations;
5524
 
        m_iNumber = p->m_iNumber;
5525
 
        m_iShowMol = p->m_iShowMol;
5526
 
        if (p->m_bTempPassed != NULL)
5527
 
        {
5528
 
                try { m_bTempPassed = new bool[g_iGesVirtAtomCount]; } catch(...) { m_bTempPassed = NULL; }
5529
 
                if (m_bTempPassed == NULL) NewException((double)g_iGesVirtAtomCount*sizeof(bool),__FILE__,__LINE__,__PRETTY_FUNCTION__);
5530
 
                
5531
 
                memcpy(m_bTempPassed,p->m_bTempPassed,sizeof(bool)*g_iGesVirtAtomCount);
5532
 
        }
5533
 
        for (z=0;z<p->m_oaConditions.GetSize();z++)
5534
 
        {
5535
 
                try { nb = new CNbSearch(); } catch(...) { nb = NULL; }
5536
 
                if (nb == NULL) NewException((double)sizeof(CNbSearch),__FILE__,__LINE__,__PRETTY_FUNCTION__);
5537
 
                
5538
 
                nb->CopyFrom((CNbSearch*)p->m_oaConditions[z]);
5539
 
                m_oaConditions.Add(nb);
5540
 
        }
5541
 
}
5542
 
 
5543
 
 
5544
 
void CConditionGroup::CopyFrom(CConditionGroup *p)
5545
 
{
5546
 
        int z;
5547
 
        CConditionSubGroup *sg;
5548
 
 
5549
 
        m_bInactive = p->m_bInactive;
5550
 
        m_iShowMol = p->m_iShowMol;
5551
 
        m_iRefMol = p->m_iRefMol;
5552
 
        m_iHistoGes = p->m_iHistoGes;
5553
 
        m_bAnyPassed = p->m_bAnyPassed;
5554
 
        m_fTableGes = p->m_fTableGes;
5555
 
        m_fPassed = p->m_fPassed;
5556
 
        m_fTotal = p->m_fTotal;
5557
 
        m_bInvertCondition = p->m_bInvertCondition;
5558
 
 
5559
 
        if (p->m_bAlwaysTrue != NULL)
5560
 
        {
5561
 
                try { m_bAlwaysTrue = new bool[((CMolecule*)g_oaMolecules[m_iShowMol])->m_laSingleMolIndex.GetSize()]; } catch(...) { m_bAlwaysTrue = NULL; }
5562
 
                if (m_bAlwaysTrue == NULL) NewException((double)((CMolecule*)g_oaMolecules[m_iShowMol])->m_laSingleMolIndex.GetSize()*sizeof(bool),__FILE__,__LINE__,__PRETTY_FUNCTION__);
5563
 
                
5564
 
                memcpy(m_bAlwaysTrue,p->m_bAlwaysTrue,sizeof(bool)*((CMolecule*)g_oaMolecules[m_iShowMol])->m_laSingleMolIndex.GetSize());
5565
 
        }
5566
 
        if (p->m_iPassCounter != NULL)
5567
 
        {
5568
 
                try { m_iPassCounter = new long[((CMolecule*)g_oaMolecules[m_iShowMol])->m_laSingleMolIndex.GetSize()]; } catch(...) { m_iPassCounter = NULL; }
5569
 
                if (m_iPassCounter == NULL) NewException((double)((CMolecule*)g_oaMolecules[m_iShowMol])->m_laSingleMolIndex.GetSize()*sizeof(long),__FILE__,__LINE__,__PRETTY_FUNCTION__);
5570
 
                
5571
 
                memcpy(m_iPassCounter,p->m_iPassCounter,sizeof(long)*((CMolecule*)g_oaMolecules[m_iShowMol])->m_laSingleMolIndex.GetSize());
5572
 
        }
5573
 
        if (p->m_iOMPassCounter != NULL)
5574
 
        {
5575
 
                try { m_iOMPassCounter = new long[((CMolecule*)g_oaMolecules[m_iShowMol])->m_laSingleMolIndex.GetSize()]; } catch(...) { m_iOMPassCounter = NULL; }
5576
 
                if (m_iOMPassCounter == NULL) NewException((double)((CMolecule*)g_oaMolecules[m_iShowMol])->m_laSingleMolIndex.GetSize()*sizeof(long),__FILE__,__LINE__,__PRETTY_FUNCTION__);
5577
 
                
5578
 
                memcpy(m_iOMPassCounter,p->m_iOMPassCounter,sizeof(long)*((CMolecule*)g_oaMolecules[m_iShowMol])->m_laSingleMolIndex.GetSize());
5579
 
        }
5580
 
        if (p->m_iRMPassCounter != NULL)
5581
 
        {
5582
 
                try { m_iRMPassCounter = new long[((CMolecule*)g_oaMolecules[m_iRefMol])->m_laSingleMolIndex.GetSize()]; } catch(...) { m_iRMPassCounter = NULL; }
5583
 
                if (m_iRMPassCounter == NULL) NewException((double)((CMolecule*)g_oaMolecules[m_iRefMol])->m_laSingleMolIndex.GetSize()*sizeof(long),__FILE__,__LINE__,__PRETTY_FUNCTION__);
5584
 
                
5585
 
                memcpy(m_iRMPassCounter,p->m_iRMPassCounter,sizeof(long)*((CMolecule*)g_oaMolecules[m_iRefMol])->m_laSingleMolIndex.GetSize());
5586
 
        }
5587
 
        for (z=0;z<p->m_oaConditionSubGroups.GetSize();z++)
5588
 
        {
5589
 
                try { sg = new CConditionSubGroup(); } catch(...) { sg = NULL; }
5590
 
                if (sg == NULL) NewException((double)sizeof(CConditionSubGroup),__FILE__,__LINE__,__PRETTY_FUNCTION__);
5591
 
                
5592
 
                sg->CopyFrom((CConditionSubGroup*)p->m_oaConditionSubGroups[z]);
5593
 
                m_oaConditionSubGroups.Add(sg);
5594
 
        }
5595
 
 
5596
 
        if (p->m_pTable != NULL)
5597
 
        {
5598
 
                try { m_pTable = new double[(((CConditionSubGroup*)m_oaConditionSubGroups[0])->m_iCombinations+1) * (((CConditionSubGroup*)m_oaConditionSubGroups[1])->m_iCombinations+1)]; } catch(...) { m_pTable = NULL; }
5599
 
                if (m_pTable == NULL) NewException((double)(((CConditionSubGroup*)m_oaConditionSubGroups[0])->m_iCombinations+1) * (((CConditionSubGroup*)m_oaConditionSubGroups[1])->m_iCombinations+1)*sizeof(double),__FILE__,__LINE__,__PRETTY_FUNCTION__);
5600
 
                
5601
 
                memcpy(m_pTable,p->m_pTable,sizeof(double)*(((CConditionSubGroup*)m_oaConditionSubGroups[0])->m_iCombinations+1) * (((CConditionSubGroup*)m_oaConditionSubGroups[1])->m_iCombinations+1));
5602
 
        }
5603
 
 
5604
 
        if (p->m_pHistogram != NULL)
5605
 
        {
5606
 
                try { m_pHistogram = new unsigned long[((CMolecule*)g_oaMolecules[m_iShowMol])->m_laSingleMolIndex.GetSize()+1]; } catch(...) { m_pHistogram = NULL; }
5607
 
                if (m_pHistogram == NULL) NewException((double)(((CMolecule*)g_oaMolecules[m_iShowMol])->m_laSingleMolIndex.GetSize()+1)*sizeof(unsigned long),__FILE__,__LINE__,__PRETTY_FUNCTION__);
5608
 
                
5609
 
                memcpy(m_pHistogram,p->m_pHistogram,sizeof(unsigned long)*(((CMolecule*)g_oaMolecules[m_iShowMol])->m_laSingleMolIndex.GetSize()+1));
5610
 
        }
5611
 
}
5612
 
 
5613
 
 
5614
 
void CConditionGroup::Parse_OnlyValues()
5615
 
{
5616
 
        BTIN;
5617
 
        int z;
5618
 
 
5619
 
        for (z=0;z<m_oaConditionSubGroups.GetSize();z++)
5620
 
        {
5621
 
                mprintf(YELLOW,">>> %d. set of conditions >>>\n\n",z+1);
5622
 
                ((CConditionSubGroup*)m_oaConditionSubGroups[z])->Parse_OnlyValues();
5623
 
                mprintf(YELLOW,"<<< End of %d. set of conditions <<<\n\n",z+1);
5624
 
        }
5625
 
}
5626
 
 
5627
 
 
5628
 
void CConditionSubGroup::Parse_OnlyValues()
5629
 
{
5630
 
        BTIN;
5631
 
        int z;
5632
 
 
5633
 
        for (z=0;z<m_oaConditions.GetSize();z++)
5634
 
        {
5635
 
                mprintf(YELLOW,"    >>> %d. condition within this set >>>\n\n",z+1);
5636
 
                ((CNbSearch*)m_oaConditions[z])->Parse_OnlyValues();
5637
 
                mprintf(YELLOW,"\n    <<< End of %d. condition <<<\n\n",z+1);
5638
 
        }
5639
 
        BTOUT;
5640
 
}
5641
 
 
5642
 
 
5643
 
void CConditionGroup::CopyResults(CConditionGroup *p)
5644
 
{
5645
 
        int z;
5646
 
 
5647
 
        for (z=0;z<m_oaConditionSubGroups.GetSize();z++)
5648
 
                ((CConditionSubGroup*)m_oaConditionSubGroups[z])->CopyResults((CConditionSubGroup*)p->m_oaConditionSubGroups[z]);
5649
 
}
5650
 
 
5651
 
 
5652
 
void CConditionSubGroup::CopyResults(CConditionSubGroup *p)
5653
 
{
5654
 
        int z;
5655
 
 
5656
 
        for (z=0;z<m_oaConditions.GetSize();z++)
5657
 
                ((CNbSearch*)m_oaConditions[z])->CopyResults((CNbSearch*)p->m_oaConditions[z]);
5658
 
}
5659
 
 
5660
 
 
5661
 
void CConditionGroup::ReScan(CSingleMolecule *rm)
5662
 
{
5663
 
        BXIN;
5664
 
        int z, z2, t1, t2, i;
5665
 
 
5666
 
        if (m_bInactive)
5667
 
                return;
5668
 
 
5669
 
        for (z=0;z<m_oaConditionSubGroups.GetSize();z++)
5670
 
                ((CConditionSubGroup*)m_oaConditionSubGroups[z])->ReScan(rm);
5671
 
 
5672
 
        if (m_oaConditionSubGroups.GetSize() == 2)
5673
 
        {
5674
 
                for (z=0;z<((CMolecule*)g_oaMolecules[m_iShowMol])->m_laSingleMolIndex.GetSize();z++)
5675
 
                {
5676
 
                        t1 = 0;
5677
 
                        t2 = 0;
5678
 
                        for (z2=0;z2<((CConditionSubGroup*)m_oaConditionSubGroups[0])->m_oaConditions.GetSize();z2++)
5679
 
                                t1 += ((CNbSearch*)((CConditionSubGroup*)m_oaConditionSubGroups[0])->m_oaConditions[z2])->m_iCombPassCount[z];
5680
 
                        for (z2=0;z2<((CConditionSubGroup*)m_oaConditionSubGroups[1])->m_oaConditions.GetSize();z2++)
5681
 
                                t2 += ((CNbSearch*)((CConditionSubGroup*)m_oaConditionSubGroups[1])->m_oaConditions[z2])->m_iCombPassCount[z];
5682
 
                        m_pTable[t1*(((CConditionSubGroup*)m_oaConditionSubGroups[1])->m_iCombinations+1)+t2]++;
5683
 
                        m_fTableGes++;
5684
 
                }
5685
 
        }
5686
 
 
5687
 
        i = 0;
5688
 
        for (z=0;z<((CMolecule*)g_oaMolecules[m_iShowMol])->m_laSingleMolIndex.GetSize();z++)
5689
 
        {
5690
 
                m_fTotal++;
5691
 
                if (m_bInvertCondition)
5692
 
                {
5693
 
                        for (z2=0;z2<m_oaConditionSubGroups.GetSize();z2++)
5694
 
                                if (((CConditionSubGroup*)m_oaConditionSubGroups[z2])->Contains(z))
5695
 
                                        goto _nopass;
5696
 
                        m_fPassed++;
5697
 
                        m_iPassCounter[z]++;
5698
 
                        m_bAnyPassed = true;
5699
 
                } else
5700
 
                {
5701
 
                        for (z2=0;z2<m_oaConditionSubGroups.GetSize();z2++)
5702
 
                                if (((CConditionSubGroup*)m_oaConditionSubGroups[z2])->Contains(z))
5703
 
                                {
5704
 
//                                      mprintf("passed[%d]++\n",z);
5705
 
                                        m_fPassed++;
5706
 
                                        m_iPassCounter[z]++;
5707
 
                                        m_bAnyPassed = true;
5708
 
                                        i++;
5709
 
                                        goto _nopass;
5710
 
                                }
5711
 
                }
5712
 
_nopass:;
5713
 
        }
5714
 
        m_pHistogram[i]++;
5715
 
        m_iHistoGes++;
5716
 
 
5717
 
        BXOUT;
5718
 
}
5719
 
 
5720
 
 
5721
 
void CConditionSubGroup::ReScan(CSingleMolecule *rm)
5722
 
{
5723
 
        int z, z2;
5724
 
 
5725
 
        for (z=0;z<m_oaConditions.GetSize();z++)
5726
 
                ((CNbSearch*)m_oaConditions[z])->ReScan(rm);
5727
 
 
5728
 
        for (z=0;z<((CMolecule*)g_oaMolecules[m_iShowMol])->m_laSingleMolIndex.GetSize();z++)
5729
 
        {
5730
 
                m_fTotal++;
5731
 
                for (z2=0;z2<m_oaConditions.GetSize();z2++)
5732
 
                        if (!((CNbSearch*)m_oaConditions[z2])->m_bPassed[z])
5733
 
                                goto _nopass;
5734
 
                m_fPassed++;
5735
 
_nopass:;
5736
 
        }
5737
 
}
5738
 
 
5739
 
 
5740
 
CNbSearch* CConditionGroup::AddSingleCondition(int rm, int sm, int gridmode)
5741
 
{
5742
 
        BTIN;
5743
 
        CConditionSubGroup *sg;
5744
 
        int z;
5745
 
 
5746
 
        m_iShowMol = sm;
5747
 
        m_iRefMol = rm;
5748
 
 
5749
 
        try { m_bAlwaysTrue = new bool[((CMolecule*)g_oaMolecules[sm])->m_laSingleMolIndex.GetSize()]; } catch(...) { m_bAlwaysTrue = NULL; }
5750
 
        if (m_bAlwaysTrue == NULL) NewException((double)((CMolecule*)g_oaMolecules[sm])->m_laSingleMolIndex.GetSize()*sizeof(bool),__FILE__,__LINE__,__PRETTY_FUNCTION__);
5751
 
        
5752
 
        try { m_iPassCounter = new long[((CMolecule*)g_oaMolecules[sm])->m_laSingleMolIndex.GetSize()]; } catch(...) { m_iPassCounter = NULL; }
5753
 
        if (m_iPassCounter == NULL) NewException((double)((CMolecule*)g_oaMolecules[sm])->m_laSingleMolIndex.GetSize()*sizeof(long),__FILE__,__LINE__,__PRETTY_FUNCTION__);
5754
 
        
5755
 
        try { m_iOMPassCounter = new long[((CMolecule*)g_oaMolecules[sm])->m_laSingleMolIndex.GetSize()]; } catch(...) { m_iOMPassCounter = NULL; }
5756
 
        if (m_iOMPassCounter == NULL) NewException((double)((CMolecule*)g_oaMolecules[sm])->m_laSingleMolIndex.GetSize()*sizeof(long),__FILE__,__LINE__,__PRETTY_FUNCTION__);
5757
 
        
5758
 
        for (z=0;z<((CMolecule*)g_oaMolecules[sm])->m_laSingleMolIndex.GetSize();z++)
5759
 
        {
5760
 
                m_bAlwaysTrue[z] = false;
5761
 
                m_iPassCounter[z] = 0;
5762
 
                m_iOMPassCounter[z] = 0;
5763
 
        }
5764
 
 
5765
 
        try { m_iRMPassCounter = new long[((CMolecule*)g_oaMolecules[rm])->m_laSingleMolIndex.GetSize()]; } catch(...) { m_iRMPassCounter = NULL; }
5766
 
        if (m_iRMPassCounter == NULL) NewException((double)((CMolecule*)g_oaMolecules[rm])->m_laSingleMolIndex.GetSize()*sizeof(long),__FILE__,__LINE__,__PRETTY_FUNCTION__);
5767
 
        
5768
 
        for (z=0;z<((CMolecule*)g_oaMolecules[rm])->m_laSingleMolIndex.GetSize();z++)
5769
 
                m_iRMPassCounter[z] = 0;
5770
 
 
5771
 
        try { sg = new CConditionSubGroup(); } catch(...) { sg = NULL; }
5772
 
        if (sg == NULL) NewException((double)sizeof(CConditionSubGroup),__FILE__,__LINE__,__PRETTY_FUNCTION__);
5773
 
        
5774
 
        sg->m_iShowMol = m_iShowMol;
5775
 
        sg->m_iNumber = m_oaConditionSubGroups.GetSize();
5776
 
        m_oaConditionSubGroups.Add(sg);
5777
 
        
5778
 
        m_bInvertCondition = false;
5779
 
 
5780
 
        m_iHistoGes = 0;
5781
 
 
5782
 
        try { m_pHistogram = new unsigned long[((CMolecule*)g_oaMolecules[sm])->m_laSingleMolIndex.GetSize()+1]; } catch(...) { m_pHistogram = NULL; }
5783
 
        if (m_pHistogram == NULL) NewException((double)(((CMolecule*)g_oaMolecules[sm])->m_laSingleMolIndex.GetSize()+1)*sizeof(unsigned long),__FILE__,__LINE__,__PRETTY_FUNCTION__);
5784
 
        
5785
 
        for (z=0;z<((CMolecule*)g_oaMolecules[sm])->m_laSingleMolIndex.GetSize()+1;z++)
5786
 
                m_pHistogram[z] = 0;
5787
 
 
5788
 
        BTOUT;
5789
 
        return sg->AddSingleCondition(rm,sm,gridmode);
5790
 
}
5791
 
 
5792
 
 
5793
 
CNbSearch* CConditionSubGroup::AddSingleCondition(int rm, int sm, int gridmode)
5794
 
{
5795
 
        BTIN;
5796
 
        CNbSearch *n;
5797
 
 
5798
 
        m_iCombinations = 0;
5799
 
 
5800
 
        try { n = new CNbSearch(); } catch(...) { n = NULL; }
5801
 
        if (n == NULL) NewException((double)sizeof(CNbSearch),__FILE__,__LINE__,__PRETTY_FUNCTION__);
5802
 
        
5803
 
        n->m_iNumber = m_oaConditions.GetSize();
5804
 
        m_oaConditions.Add(n);
5805
 
        n->ParseGrid(rm,sm,gridmode);
5806
 
        m_iCombinations += n->m_iCombinationsEnabled;
5807
 
 
5808
 
        try { m_bTempPassed = new bool[g_iGesVirtAtomCount]; } catch(...) { m_bTempPassed = NULL; }
5809
 
        if (m_bTempPassed == NULL) NewException((double)g_iGesVirtAtomCount*sizeof(bool),__FILE__,__LINE__,__PRETTY_FUNCTION__);
5810
 
 
5811
 
        BTOUT;
5812
 
        return n;
5813
 
}
5814
 
 
5815
 
 
5816
 
void CObservation::BuildTimeDiff(CDF *df, bool ddf)
5817
 
{
5818
 
        int z, z2, z3, z4, i;
5819
 
        CxFloatArray *ptfa;
5820
 
        double tf, tfa, tfsq, tfs, tf0;
5821
 
        char buf[256];
5822
 
 
5823
 
        try { df->m_pTimeDiff = new CDF(); } catch(...) { df->m_pTimeDiff = NULL; }
5824
 
        if (df->m_pTimeDiff == NULL) NewException((double)sizeof(CDF),__FILE__,__LINE__,__PRETTY_FUNCTION__);
5825
 
        
5826
 
        df->m_pTimeDiff->m_iResolution = m_iTimeDiffDepth;
5827
 
        df->m_pTimeDiff->m_fMinVal = 0;
5828
 
        df->m_pTimeDiff->m_fMaxVal = m_iTimeDiffDepth * g_fTimestepLength / 1000.0;
5829
 
        df->m_pTimeDiff->Create();
5830
 
        df->m_pTimeDiff->SetLabelX("Tau [ps]");
5831
 
        sprintf(buf,"Delta ");
5832
 
        strcat(buf,df->m_sLabelX);
5833
 
        df->m_pTimeDiff->SetLabelY(buf);
5834
 
 
5835
 
        try { df->m_pTimeDiffAbs = new CDF(); } catch(...) { df->m_pTimeDiffAbs = NULL; }
5836
 
        if (df->m_pTimeDiffAbs == NULL) NewException((double)sizeof(CDF),__FILE__,__LINE__,__PRETTY_FUNCTION__);
5837
 
        
5838
 
        df->m_pTimeDiffAbs->m_iResolution = m_iTimeDiffDepth;
5839
 
        df->m_pTimeDiffAbs->m_fMinVal = 0;
5840
 
        df->m_pTimeDiffAbs->m_fMaxVal = m_iTimeDiffDepth * g_fTimestepLength / 1000.0;
5841
 
        df->m_pTimeDiffAbs->Create();
5842
 
        df->m_pTimeDiffAbs->SetLabelX("Tau [ps]");
5843
 
        df->m_pTimeDiffAbs->SetLabelY(buf);
5844
 
 
5845
 
        sprintf(buf,"Delta Square ");
5846
 
        strcat(buf,df->m_sLabelX);
5847
 
 
5848
 
        try { df->m_pTimeDiffSqr = new CDF(); } catch(...) { df->m_pTimeDiffSqr = NULL; }
5849
 
        if (df->m_pTimeDiffSqr == NULL) NewException((double)sizeof(CDF),__FILE__,__LINE__,__PRETTY_FUNCTION__);
5850
 
        
5851
 
        df->m_pTimeDiffSqr->m_iResolution = m_iTimeDiffDepth;
5852
 
        df->m_pTimeDiffSqr->m_fMinVal = 0;
5853
 
        df->m_pTimeDiffSqr->m_fMaxVal = m_iTimeDiffDepth * g_fTimestepLength / 1000.0;
5854
 
        df->m_pTimeDiffSqr->Create();
5855
 
        df->m_pTimeDiffSqr->SetLabelX("Tau [ps]");
5856
 
        df->m_pTimeDiffSqr->SetLabelY(buf);
5857
 
 
5858
 
        if (m_b3DTimeDiff)
5859
 
        {
5860
 
                sprintf(buf,"Delta ");
5861
 
                strcat(buf,df->m_sLabelX);
5862
 
 
5863
 
                try { df->m_p3DTimeDiff = new C2DF(); } catch(...) { df->m_p3DTimeDiff = NULL; }
5864
 
                if (df->m_p3DTimeDiff == NULL) NewException((double)sizeof(C2DF),__FILE__,__LINE__,__PRETTY_FUNCTION__);
5865
 
                
5866
 
                df->m_p3DTimeDiff->m_iRes[0] = m_iTimeDiffDepth/m_iTimeDiffStride3D;
5867
 
                df->m_p3DTimeDiff->m_iRes[1] = m_iTimeDiffRes3D;
5868
 
                df->m_p3DTimeDiff->m_fMinVal[0] = 0;
5869
 
                df->m_p3DTimeDiff->m_fMaxVal[0] = m_iTimeDiffDepth * g_fTimestepLength / 1000.0;
5870
 
                df->m_p3DTimeDiff->m_fMinVal[1] = m_fTimeDiffMinVal3D;
5871
 
                df->m_p3DTimeDiff->m_fMaxVal[1] = m_fTimeDiffMaxVal3D;
5872
 
                df->m_p3DTimeDiff->Create();
5873
 
                df->m_p3DTimeDiff->SetLabelX("Tau [ps]");
5874
 
                df->m_p3DTimeDiff->SetLabelY(df->m_sLabelX);
5875
 
                df->m_p3DTimeDiff->SetLabelZ(buf);
5876
 
 
5877
 
                try { df->m_p3DTimeDiffAbs = new C2DF(); } catch(...) { df->m_p3DTimeDiffAbs = NULL; }
5878
 
                if (df->m_p3DTimeDiffAbs == NULL) NewException((double)sizeof(C2DF),__FILE__,__LINE__,__PRETTY_FUNCTION__);
5879
 
                
5880
 
                df->m_p3DTimeDiffAbs->m_iRes[0] = m_iTimeDiffDepth/m_iTimeDiffStride3D;
5881
 
                df->m_p3DTimeDiffAbs->m_iRes[1] = m_iTimeDiffRes3D;
5882
 
                df->m_p3DTimeDiffAbs->m_fMinVal[0] = 0;
5883
 
                df->m_p3DTimeDiffAbs->m_fMaxVal[0] = m_iTimeDiffDepth * g_fTimestepLength / 1000.0;
5884
 
                df->m_p3DTimeDiffAbs->m_fMinVal[1] = m_fTimeDiffMinVal3D;
5885
 
                df->m_p3DTimeDiffAbs->m_fMaxVal[1] = m_fTimeDiffMaxVal3D;
5886
 
                df->m_p3DTimeDiffAbs->Create();
5887
 
                df->m_p3DTimeDiffAbs->SetLabelX("Tau [ps]");
5888
 
                df->m_p3DTimeDiffAbs->SetLabelY(df->m_sLabelX);
5889
 
                df->m_p3DTimeDiffAbs->SetLabelZ(buf);
5890
 
 
5891
 
                if (m_iTimeDiffDistSteps != 0)
5892
 
                {
5893
 
                        try { df->m_pTimeDiffDistPairs = new C2DF*[m_iTimeDiffDepth/m_iTimeDiffStride3D/m_iTimeDiffDistSteps]; } catch(...) { df->m_pTimeDiffDistPairs = NULL; }
5894
 
                        if (df->m_pTimeDiffDistPairs == NULL) NewException((double)m_iTimeDiffDepth/m_iTimeDiffStride3D/m_iTimeDiffDistSteps*sizeof(C2DF*),__FILE__,__LINE__,__PRETTY_FUNCTION__);
5895
 
                        
5896
 
                        for (z=0;z<m_iTimeDiffDepth/m_iTimeDiffStride3D/m_iTimeDiffDistSteps;z++)
5897
 
                        {
5898
 
                                try { df->m_pTimeDiffDistPairs[z] = new C2DF(); } catch(...) { df->m_pTimeDiffDistPairs[z] = NULL; }
5899
 
                                if (df->m_pTimeDiffDistPairs[z] == NULL) NewException((double)sizeof(C2DF),__FILE__,__LINE__,__PRETTY_FUNCTION__);
5900
 
                                
5901
 
                                df->m_pTimeDiffDistPairs[z]->m_iRes[0] = m_iTimeDiffDistResX;
5902
 
                                df->m_pTimeDiffDistPairs[z]->m_iRes[1] = m_iTimeDiffDistResY;
5903
 
                                df->m_pTimeDiffDistPairs[z]->m_fMinVal[0] = m_fTimeDiffDistMinValX;
5904
 
                                df->m_pTimeDiffDistPairs[z]->m_fMaxVal[0] = m_fTimeDiffDistMaxValX;
5905
 
                                df->m_pTimeDiffDistPairs[z]->m_fMinVal[1] = m_fTimeDiffDistMinValY;
5906
 
                                df->m_pTimeDiffDistPairs[z]->m_fMaxVal[1] = m_fTimeDiffDistMaxValY;
5907
 
                                df->m_pTimeDiffDistPairs[z]->Create();
5908
 
                                df->m_pTimeDiffDistPairs[z]->SetLabelX(df->m_sLabelX);
5909
 
                                df->m_pTimeDiffDistPairs[z]->SetLabelY(df->m_sLabelX);
5910
 
                        }
5911
 
                }
5912
 
 
5913
 
                try { df->m_pTimeDiffDist3DF = new C3DF(); } catch(...) { df->m_pTimeDiffDist3DF = NULL; }
5914
 
                if (df->m_pTimeDiffDist3DF == NULL) NewException((double)sizeof(C3DF),__FILE__,__LINE__,__PRETTY_FUNCTION__);
5915
 
                
5916
 
                df->m_pTimeDiffDist3DF->m_iRes[0] = m_iTimeDiffDistResX;
5917
 
                df->m_pTimeDiffDist3DF->m_iRes[1] = m_iTimeDiffDistResY;
5918
 
                df->m_pTimeDiffDist3DF->m_iRes[2] = m_iTimeDiffDepth/m_iTimeDiffStride3D;
5919
 
                df->m_pTimeDiffDist3DF->m_fMinVal[0] = m_fTimeDiffDistMinValX;
5920
 
                df->m_pTimeDiffDist3DF->m_fMaxVal[0] = m_fTimeDiffDistMaxValX;
5921
 
                df->m_pTimeDiffDist3DF->m_fMinVal[1] = m_fTimeDiffDistMinValY;
5922
 
                df->m_pTimeDiffDist3DF->m_fMaxVal[1] = m_fTimeDiffDistMaxValY;
5923
 
                df->m_pTimeDiffDist3DF->m_fMinVal[2] = 0;
5924
 
                df->m_pTimeDiffDist3DF->m_fMaxVal[2] = m_iTimeDiffDepth * g_fTimestepLength / 1000.0;
5925
 
                df->m_pTimeDiffDist3DF->Create();
5926
 
                df->m_pTimeDiffDist3DF->SetLabelX(df->m_sLabelX);
5927
 
                df->m_pTimeDiffDist3DF->SetLabelY(df->m_sLabelX);
5928
 
 
5929
 
                sprintf(buf,"Delta Square ");
5930
 
                strcat(buf,df->m_sLabelX);
5931
 
 
5932
 
                try { df->m_p3DTimeDiffSqr = new C2DF(); } catch(...) { df->m_p3DTimeDiffSqr = NULL; }
5933
 
                if (df->m_p3DTimeDiffSqr == NULL) NewException((double)sizeof(C3DF),__FILE__,__LINE__,__PRETTY_FUNCTION__);
5934
 
                
5935
 
                df->m_p3DTimeDiffSqr->m_iRes[0] = m_iTimeDiffDepth/m_iTimeDiffStride3D;
5936
 
                df->m_p3DTimeDiffSqr->m_iRes[1] = m_iTimeDiffRes3D;
5937
 
                df->m_p3DTimeDiffSqr->m_fMinVal[0] = 0;
5938
 
                df->m_p3DTimeDiffSqr->m_fMaxVal[0] = m_iTimeDiffDepth * g_fTimestepLength / 1000.0;
5939
 
                df->m_p3DTimeDiffSqr->m_fMinVal[1] = m_fTimeDiffMinVal3D;
5940
 
                df->m_p3DTimeDiffSqr->m_fMaxVal[1] = m_fTimeDiffMaxVal3D;
5941
 
                df->m_p3DTimeDiffSqr->Create();
5942
 
                df->m_p3DTimeDiffSqr->SetLabelX("Tau [ps]");
5943
 
                df->m_p3DTimeDiffSqr->SetLabelY(df->m_sLabelX);
5944
 
                df->m_p3DTimeDiffSqr->SetLabelZ(buf);
5945
 
 
5946
 
                try { df->m_p3DTimeDiffT = new C2DF(); } catch(...) { df->m_p3DTimeDiffT = NULL; }
5947
 
                if (df->m_p3DTimeDiffT == NULL) NewException((double)sizeof(C2DF),__FILE__,__LINE__,__PRETTY_FUNCTION__);
5948
 
                
5949
 
                df->m_p3DTimeDiffT->m_iRes[0] = m_iTimeDiffDepth/m_iTimeDiffStride3D;
5950
 
                df->m_p3DTimeDiffT->m_iRes[1] = m_iTimeDiffRes3D;
5951
 
                df->m_p3DTimeDiffT->m_fMinVal[0] = 0;
5952
 
                df->m_p3DTimeDiffT->m_fMaxVal[0] = m_iTimeDiffDepth * g_fTimestepLength / 1000.0;
5953
 
                df->m_p3DTimeDiffT->m_fMinVal[1] = m_fTimeDiffMinVal3D;
5954
 
                df->m_p3DTimeDiffT->m_fMaxVal[1] = m_fTimeDiffMaxVal3D;
5955
 
                df->m_p3DTimeDiffT->Create();
5956
 
        }
5957
 
 
5958
 
        for (z2=0;z2<df->m_oaTimeDiffBuf.GetSize();z2++)
5959
 
        {
5960
 
                mprintf("      %4d/%d 2D  [",z2+1,df->m_oaTimeDiffBuf.GetSize());
5961
 
                ptfa = (CxFloatArray*)df->m_oaTimeDiffBuf[z2];
5962
 
                tfs = m_iTimeDiffDepth/50.0;
5963
 
                for (z3=0;z3<m_iTimeDiffDepth;z3++) // Das ist das Tau
5964
 
                {
5965
 
                        if (fmod(z3,tfs) < 1.0)
5966
 
                                mprintf(WHITE,"#");
5967
 
                        tf = 0;
5968
 
                        tfa = 0;
5969
 
                        tfsq = 0;
5970
 
                        for (z4=0;z4<(int)ptfa->GetSize()-z3-1;z4++) // Das ist der Startpunkt
5971
 
                        {
5972
 
                                tf0 = (*ptfa)[z3+z4]-(*ptfa)[z4];
5973
 
                                if (ddf)
5974
 
                                {
5975
 
                                        if (tf0 > 180.0)
5976
 
                                                tf0 -= 360.0;
5977
 
                                        if (tf0 <= -180.0)
5978
 
                                                tf0 += 360.0;
5979
 
                                }
5980
 
                                tfa += fabs(tf0);
5981
 
                                tf += tf0;
5982
 
                                tfsq += tf0 * tf0;
5983
 
                        }
5984
 
                        df->m_pTimeDiff->AddToBin_Int(z3,tf/(ptfa->GetSize()-z3-1));
5985
 
                        df->m_pTimeDiffAbs->AddToBin_Int(z3,tfa/(ptfa->GetSize()-z3-1));
5986
 
                        df->m_pTimeDiffSqr->AddToBin_Int(z3,tfsq/(ptfa->GetSize()-z3-1));
5987
 
 
5988
 
                        df->m_pTimeDiff->m_fBinEntries += ptfa->GetSize()-z3-2;
5989
 
                        df->m_pTimeDiffAbs->m_fBinEntries += ptfa->GetSize()-z3-2;
5990
 
                        df->m_pTimeDiffSqr->m_fBinEntries += ptfa->GetSize()-z3-2;
5991
 
                }
5992
 
                mprintf("]\n");
5993
 
                if (m_b3DTimeDiff)
5994
 
                {
5995
 
                        mprintf("      %4d/%d 3D  [",z2+1,df->m_oaTimeDiffBuf.GetSize());
5996
 
                        tfs = m_iTimeDiffDepth/50.0;
5997
 
                        for (z3=0;z3<m_iTimeDiffDepth;z3+=m_iTimeDiffStride3D) // Das ist das Tau
5998
 
                        {
5999
 
                                if (fmod(z3,tfs) < 1.0)
6000
 
                                        mprintf(WHITE,"#");
6001
 
                                i = z3/m_iTimeDiffStride3D;
6002
 
                                for (z4=0;z4<(int)ptfa->GetSize()-z3-1;z4++) // Das ist der Startpunkt
6003
 
                                {
6004
 
                                        tf0 = (*ptfa)[z3+z4]-(*ptfa)[z4];
6005
 
                                        if (ddf)
6006
 
                                        {
6007
 
                                                if (tf0 > 180.0)
6008
 
                                                        tf0 -= 360.0;
6009
 
                                                if (tf0 <= -180.0)
6010
 
                                                        tf0 += 360.0;
6011
 
                                        }
6012
 
                                        df->m_p3DTimeDiff->AddToBin_IntX(i,(*ptfa)[z4],tf0);
6013
 
                                        df->m_p3DTimeDiffAbs->AddToBin_IntX(i,(*ptfa)[z4],fabs(tf0));
6014
 
                                        df->m_p3DTimeDiffSqr->AddToBin_IntX(i,(*ptfa)[z4],tf0*tf0);
6015
 
                                        df->m_p3DTimeDiffT->AddToBin_IntX(i,(*ptfa)[z4],1.0);
6016
 
                                        df->m_pTimeDiffDist3DF->AddToBin_IntZ((*ptfa)[z4],(*ptfa)[z3+z4],i);
6017
 
                                        if (m_iTimeDiffDistSteps != 0)
6018
 
                                                if ((i % m_iTimeDiffDistSteps) == 0)
6019
 
                                                        df->m_pTimeDiffDistPairs[i/m_iTimeDiffDistSteps]->AddToBin((*ptfa)[z4],(*ptfa)[z3+z4]);
6020
 
                                }
6021
 
                        }
6022
 
                        mprintf("]\n");
6023
 
                }
6024
 
        }
6025
 
        for (z3=0;z3<m_iTimeDiffDepth;z3++) // Das ist das Tau
6026
 
        {
6027
 
                df->m_pTimeDiff->m_pBin[z3] /= df->m_oaTimeDiffBuf.GetSize();
6028
 
                df->m_pTimeDiffAbs->m_pBin[z3] /= df->m_oaTimeDiffBuf.GetSize();
6029
 
                df->m_pTimeDiffSqr->m_pBin[z3] /= df->m_oaTimeDiffBuf.GetSize();
6030
 
        }
6031
 
        if (m_b3DTimeDiff)
6032
 
        {
6033
 
                for (z2=0;z2<df->m_p3DTimeDiff->m_iRes[0]*df->m_p3DTimeDiff->m_iRes[1];z2++)
6034
 
                {
6035
 
                        if (df->m_p3DTimeDiffT->m_pBin[z2] != 0)
6036
 
                        {
6037
 
                                df->m_p3DTimeDiff->m_pBin[z2] /= df->m_p3DTimeDiffT->m_pBin[z2];
6038
 
                                df->m_p3DTimeDiffAbs->m_pBin[z2] /= df->m_p3DTimeDiffT->m_pBin[z2];
6039
 
                                df->m_p3DTimeDiffSqr->m_pBin[z2] /= df->m_p3DTimeDiffT->m_pBin[z2];
6040
 
                        }
6041
 
                }
6042
 
                if (m_iTimeDiffDistSteps != 0)
6043
 
                        for (z=0;z<m_iTimeDiffDepth/m_iTimeDiffStride3D/m_iTimeDiffDistSteps;z++)
6044
 
                                df->m_pTimeDiffDistPairs[z]->NormalizeBinIntegral(1000000.0);
6045
 
        }
6046
 
}
6047
 
 
6048
 
 
6049
 
void CObservation::WriteTimeDiff(CDF *df, const char *anaup, const char *analow, const char *name, const char *multibuf, bool ddf)
6050
 
{
6051
 
        char buf[256];
6052
 
        int z, z2;
6053
 
        C3DF *temp3DF;
6054
 
 
6055
 
        mprintf("    Creating temporal difference plot...\n");
6056
 
        BuildTimeDiff(df,ddf);
6057
 
        mprintf("      (%.0f bin entries)\n",df->m_pTimeDiff->m_fBinEntries);
6058
 
        sprintf(buf,"%s_timediff_%s%s.csv",analow,name,multibuf);
6059
 
        mprintf("      Saving %s temporal difference plot as \"%s\"...\n",anaup,buf);
6060
 
        df->m_pTimeDiff->Write("",buf,"",true);
6061
 
        sprintf(buf,"%s_timediff_%s%s.agr",analow,name,multibuf);
6062
 
        mprintf("      Saving %s temporal difference plot AGR file as \"%s\"...\n",anaup,buf);
6063
 
        df->m_pTimeDiff->WriteAgr("",buf,"",name,false);
6064
 
 
6065
 
        sprintf(buf,"%s_timediff_%s%s_abs.csv",analow,name,multibuf);
6066
 
        mprintf("      Saving %s absolute temporal difference plot as \"%s\"...\n",anaup,buf);
6067
 
        df->m_pTimeDiffAbs->Write("",buf,"",true);
6068
 
        sprintf(buf,"%s_timediff_%s%s_abs.agr",analow,name,multibuf);
6069
 
        mprintf("      Saving %s absolute temporal difference plot AGR file as \"%s\"...\n",anaup,buf);
6070
 
        df->m_pTimeDiffAbs->WriteAgr("",buf,"",name,false);
6071
 
 
6072
 
        sprintf(buf,"%s_timediff_%s%s_sqr.csv",analow,name,multibuf);
6073
 
        mprintf("      Saving %s squared temporal difference plot as \"%s\"...\n",anaup,buf);
6074
 
        df->m_pTimeDiffSqr->Write("",buf,"",true);
6075
 
        sprintf(buf,"%s_timediff_%s%s_sqr.agr",analow,name,multibuf);
6076
 
        mprintf("      Saving %s squared temporal difference plot AGR file as \"%s\"...\n",anaup,buf);
6077
 
        df->m_pTimeDiffSqr->WriteAgr("",buf,"",name,false);
6078
 
 
6079
 
        if (m_b3DTimeDiff)
6080
 
        {
6081
 
                mprintf("    Writing temporal 3D difference plot...\n");
6082
 
                mprintf("      (%.0f bin entries)\n",df->m_p3DTimeDiff->m_fBinEntries);
6083
 
                sprintf(buf,"%s_timediff_%s%s_triples.csv",analow,name,multibuf);
6084
 
                mprintf("      Saving %s temporal difference plot triples as \"%s\"...\n",anaup,buf);
6085
 
                df->m_p3DTimeDiff->Write("",buf,"");
6086
 
                sprintf(buf,"%s_timediff_%s%s_matrix.csv",analow,name,multibuf);
6087
 
                mprintf("      Saving %s temporal difference plot matrix as \"%s\"...\n",anaup,buf);
6088
 
                df->m_p3DTimeDiff->WriteCSV("",buf,"");
6089
 
                sprintf(buf,"%s_timediff_%s%s.nb",analow,name,multibuf);
6090
 
                mprintf("      Saving %s temporal difference plot Mathematica Notebook as \"%s\"...\n",anaup,buf);
6091
 
                df->m_p3DTimeDiff->WriteMathematicaNb("",buf,"",false);
6092
 
                sprintf(buf,"%s_timediff_%s%s",analow,name,multibuf);
6093
 
                mprintf("      Saving %s temporal difference plot Gnuplot Input as \"%s.gp\"...\n",anaup,buf);
6094
 
                df->m_p3DTimeDiff->WriteGnuplotInput("",buf,"",false);
6095
 
 
6096
 
                sprintf(buf,"%s_timediff_%s%s_triples_abs.csv",analow,name,multibuf);
6097
 
                mprintf("      Saving %s absolute temporal difference plot triples as \"%s\"...\n",anaup,buf);
6098
 
                df->m_p3DTimeDiffAbs->Write("",buf,"");
6099
 
                sprintf(buf,"%s_timediff_%s%s_matrix_abs.csv",analow,name,multibuf);
6100
 
                mprintf("      Saving %s absolute temporal difference plot matrix as \"%s\"...\n",anaup,buf);
6101
 
                df->m_p3DTimeDiffAbs->WriteCSV("",buf,"");
6102
 
                sprintf(buf,"%s_timediff_%s%s_abs.nb",analow,name,multibuf);
6103
 
                mprintf("      Saving %s absolute temporal difference plot Mathematica Notebook as \"%s\"...\n",anaup,buf);
6104
 
                df->m_p3DTimeDiffAbs->WriteMathematicaNb("",buf,"",false);
6105
 
                sprintf(buf,"%s_timediff_%s%s_abs",analow,name,multibuf);
6106
 
                mprintf("      Saving %s absolute temporal difference plot Gnuplot Input as \"%s.gp\"...\n",anaup,buf);
6107
 
                df->m_p3DTimeDiffAbs->WriteGnuplotInput("",buf,"",false);
6108
 
 
6109
 
                sprintf(buf,"%s_timediff_%s%s_triples_sqr.csv",analow,name,multibuf);
6110
 
                mprintf("      Saving %s squared temporal difference plot triples as \"%s\"...\n",anaup,buf);
6111
 
                df->m_p3DTimeDiffSqr->Write("",buf,"");
6112
 
                sprintf(buf,"%s_timediff_%s%s_matrix_sqr.csv",analow,name,multibuf);
6113
 
                mprintf("      Saving %s squared temporal difference plot matrix as \"%s\"...\n",anaup,buf);
6114
 
                df->m_p3DTimeDiffSqr->WriteCSV("",buf,"");
6115
 
                sprintf(buf,"%s_timediff_%s%s_sqr.nb",analow,name,multibuf);
6116
 
                mprintf("      Saving %s squared temporal difference plot Mathematica Notebook as \"%s\"...\n",anaup,buf);
6117
 
                df->m_p3DTimeDiffSqr->WriteMathematicaNb("",buf,"",false);
6118
 
                sprintf(buf,"%s_timediff_%s%s_sqr",analow,name,multibuf);
6119
 
                mprintf("      Saving %s squared temporal difference plot Gnuplot Input as \"%s.gp\"...\n",anaup,buf);
6120
 
                df->m_p3DTimeDiffSqr->WriteGnuplotInput("",buf,"",false);
6121
 
 
6122
 
                if (m_iTimeDiffDistSteps != 0)
6123
 
                {
6124
 
                        for (z=0;z<m_iTimeDiffDepth/m_iTimeDiffStride3D/m_iTimeDiffDistSteps;z++)
6125
 
                        {
6126
 
                                sprintf(buf,"%s_timediff_beforeafter_%s%s_tau%.3f_triples.csv",analow,name,multibuf,z*m_iTimeDiffStride3D*m_iTimeDiffDistSteps*g_fTimestepLength/1000.0);
6127
 
                                mprintf("      Saving %s before/after plot triples as \"%s\"...\n",anaup,buf);
6128
 
                                df->m_pTimeDiffDistPairs[z]->Write("",buf,"");
6129
 
                                sprintf(buf,"%s_timediff_beforeafter_%s%s_tau%.3f_matrix.csv",analow,name,multibuf,z*m_iTimeDiffStride3D*m_iTimeDiffDistSteps*g_fTimestepLength/1000.0);
6130
 
                                mprintf("      Saving %s before/after plot matrix as \"%s\"...\n",anaup,buf);
6131
 
                                df->m_pTimeDiffDistPairs[z]->WriteCSV("",buf,"");
6132
 
                                sprintf(buf,"%s_timediff_beforeafter_%s%s_tau%.3f.nb",analow,name,multibuf,z*m_iTimeDiffStride3D*m_iTimeDiffDistSteps*g_fTimestepLength/1000.0);
6133
 
                                mprintf("      Saving %s before/after plot Mathematica Notebook as \"%s\"...\n",anaup,buf);
6134
 
                                df->m_pTimeDiffDistPairs[z]->WriteMathematicaNb("",buf,"",false);
6135
 
                                sprintf(buf,"%s_timediff_beforeafter_%s%s_tau%.3f",analow,name,multibuf,z*m_iTimeDiffStride3D*m_iTimeDiffDistSteps*g_fTimestepLength/1000.0);
6136
 
                                mprintf("      Saving %s before/after plot Gnuplot Input as \"%s.gp\"...\n",anaup,buf);
6137
 
                                df->m_pTimeDiffDistPairs[z]->WriteGnuplotInput("",buf,"",false);
6138
 
                        }
6139
 
                }
6140
 
                for (z2=0;z2<=3;z2++)
6141
 
                {
6142
 
                        try { temp3DF = new C3DF(); } catch(...) { temp3DF = NULL; }
6143
 
                        if (temp3DF == NULL) NewException((double)sizeof(C3DF),__FILE__,__LINE__,__PRETTY_FUNCTION__);
6144
 
                        
6145
 
                        temp3DF->CopyFrom(df->m_pTimeDiffDist3DF);
6146
 
                        if (z2 != 0)
6147
 
                        {
6148
 
                                temp3DF->Smooth(z2);
6149
 
                                sprintf(buf,".s%d%s.plt",z2,multibuf);
6150
 
                        } else sprintf(buf,"%s.plt",multibuf);
6151
 
                        mprintf("    Saving 3D Plot as \"%s%s\"...\n",name,buf);
6152
 
                        temp3DF->WritePLT("",name,buf,false);
6153
 
 
6154
 
                        if (z2 != 0)
6155
 
                                sprintf(buf,".s%d%s.cube",z2,multibuf);
6156
 
                                        else sprintf(buf,"%s.cube",multibuf);
6157
 
                        mprintf("    Saving 3D Plot as \"%s%s\"...\n",name,buf);
6158
 
                        temp3DF->WriteCube("",name,buf,false);
6159
 
                }
6160
 
        }
6161
 
}
6162
 
 
6163
 
 
6164
 
void CObservation::CreateTimeDiff(CDF *df, int comb)
6165
 
{
6166
 
        int z2;
6167
 
        CxFloatArray *ptfa;
6168
 
 
6169
 
        if (m_bSelf)
6170
 
        {
6171
 
                for (z2=0;z2<((CMolecule*)g_oaMolecules[g_iFixMol])->m_laSingleMolIndex.GetSize()*comb;z2++)
6172
 
                {
6173
 
                        try { ptfa = new CxFloatArray("CObservation::CreateTimeDiff():ptfa"); } catch(...) { ptfa = NULL; }
6174
 
                        if (ptfa == NULL) NewException((double)sizeof(CxFloatArray),__FILE__,__LINE__,__PRETTY_FUNCTION__);
6175
 
                        
6176
 
                        if (g_iTrajSteps != -1)
6177
 
                        {
6178
 
                                ptfa->SetMaxSize((long)(g_iTrajSteps*1.1));
6179
 
                                ptfa->SetGrow((long)(g_iTrajSteps*0.1));
6180
 
                        } else ptfa->SetGrow(1000);
6181
 
                        df->m_oaTimeDiffBuf.Add(ptfa);
6182
 
                }
6183
 
        } else
6184
 
        {
6185
 
                for (z2=0;z2<((CMolecule*)g_oaMolecules[g_iFixMol])->m_laSingleMolIndex.GetSize()*((CMolecule*)g_oaMolecules[m_iShowMol])->m_laSingleMolIndex.GetSize()*comb;z2++)
6186
 
                {
6187
 
                        try { ptfa = new CxFloatArray("CObservation::CreateTimeDiff():ptfa"); } catch(...) { ptfa = NULL; }
6188
 
                        if (ptfa == NULL) NewException((double)sizeof(CxFloatArray),__FILE__,__LINE__,__PRETTY_FUNCTION__);
6189
 
                        
6190
 
                        if (g_iTrajSteps != -1)
6191
 
                        {
6192
 
                                ptfa->SetMaxSize((long)(g_iTrajSteps*1.1));
6193
 
                                ptfa->SetGrow((long)(g_iTrajSteps*0.1));
6194
 
                        } else ptfa->SetGrow(1000);
6195
 
                        df->m_oaTimeDiffBuf.Add(ptfa);
6196
 
                }
6197
 
        }
6198
 
}
6199
 
 
6200
 
 
6201
 
void CMSD::WriteSplit(const char *s)
6202
 
{
6203
 
        FILE *a;
6204
 
        int z, z2, z3;
6205
 
        CAF *af;
6206
 
 
6207
 
        a = OpenFileWrite(s,true);
6208
 
        mfprintf(a,"# tau [ps];  Total MSD [pm^2]");
6209
 
 
6210
 
        for (z=0;z<m_pAtomGroup->m_oaAtoms.GetSize();z++)
6211
 
                for (z2=0;z2<((CxIntArray*)m_pAtomGroup->m_oaAtoms[z])->GetSize();z2++)
6212
 
                        for (z3=0;z3<((CMolecule*)g_oaMolecules[m_iShowMol])->m_laSingleMolIndex.GetSize();z3++)
6213
 
                        {
6214
 
                                if (m_pAtomGroup->m_baRealAtomType[z] == g_iVirtAtomType)
6215
 
                                        mfprintf(a,";  Mol. %d #%d",z3+1,((CxIntArray*)m_pAtomGroup->m_oaAtoms[z])->GetAt(z2)+1);
6216
 
                                                else mfprintf(a,";  Mol. %d %s%d",z3+1,((CAtom*)g_oaAtoms[m_pAtomGroup->m_baRealAtomType[z]])->m_sName,((CxIntArray*)m_pAtomGroup->m_oaAtoms[z])->GetAt(z2)+1);
6217
 
                        }
6218
 
        mfprintf(a,"\n");
6219
 
 
6220
 
        for (z=0;z<m_pMSD->m_iResolution;z++)
6221
 
        {
6222
 
                mfprintf(a,"%f;  %f",m_pMSD->m_fMinVal+z*(m_pMSD->m_fMaxVal-m_pMSD->m_fMinVal)/m_pMSD->m_iResolution,m_pMSD->m_pBin[z]);
6223
 
 
6224
 
                for (z2=0;z2<m_pAtomGroup->m_iAtomGes;z2++)
6225
 
                        for (z3=0;z3<((CMolecule*)g_oaMolecules[m_iShowMol])->m_laSingleMolIndex.GetSize();z3++)
6226
 
                        {
6227
 
                                af = m_pSplitMSD[z2*((CMolecule*)g_oaMolecules[m_iShowMol])->m_laSingleMolIndex.GetSize()+z3];
6228
 
                                mfprintf(a,";  %f",af->m_pBin[z]);
6229
 
                        }
6230
 
                mfprintf(a,"\n");
6231
 
        }
6232
 
 
6233
 
        fclose(a);
6234
 
}
 
4678
        m_pPlProj = NULL;
 
4679
        m_bBinOnlyPassedAtoms = false;
 
4680
        m_bBinOnlyNotPassedAtoms = false;
 
4681
 
 
4682
        m_waSaveRefList.SetName("CObservation::m_waSaveRefList");
 
4683
        m_waSaveShowList.SetName("CObservation::m_waSaveShowList");
 
4684
        m_waObsRefList.SetName("CObservation::m_waObsRefList");
 
4685
        m_waObsShowList.SetName("CObservation::m_waObsShowList");
 
4686
        m_waObsShow2List.SetName("CObservation::m_waObsShow2List");
 
4687
        m_waDecompTypeRefOffs.SetName("CObservation::m_waDecompTypeRefOffs");
 
4688
        m_waDecompTypeObsOffs.SetName("CObservation::m_waDecompTypeObsOffs");
 
4689
        m_waDecompTypeRefList.SetName("CObservation::m_waDecompTypeRefList");
 
4690
        m_waDecompTypeObsList.SetName("CObservation::m_waDecompTypeObsList");
 
4691
        m_iaRMRegions.SetName("CObservation::m_iaRMRegions");
 
4692
        m_iaOM1Regions.SetName("CObservation::m_iaOM1Regions");
 
4693
        m_iaOM2Regions.SetName("CObservation::m_iaOM2Regions");
 
4694
}
 
4695
 
 
4696
 
 
4697
CObservation::~CObservation()
 
4698
{
 
4699
        int z;
 
4700
 
 
4701
        if (m_pConditions != NULL)
 
4702
        {
 
4703
                delete m_pConditions;
 
4704
                m_pConditions = NULL;
 
4705
        }
 
4706
        if (m_pMSD != NULL)
 
4707
        {
 
4708
                delete m_pMSD;
 
4709
                m_pMSD = NULL;
 
4710
        }
 
4711
        if (m_pSDF != NULL)
 
4712
        {
 
4713
                delete m_pSDF;
 
4714
                m_pSDF = NULL;
 
4715
        }
 
4716
        if (m_pCDF != NULL)
 
4717
        {
 
4718
                delete m_pCDF;
 
4719
                m_pCDF = NULL;
 
4720
        }
 
4721
        if (m_pVACF != NULL)
 
4722
        {
 
4723
                delete m_pVACF;
 
4724
                m_pVACF = NULL;
 
4725
        }
 
4726
        if (m_pDipACF != NULL)
 
4727
        {
 
4728
                delete m_pDipACF;
 
4729
                m_pDipACF = NULL;
 
4730
        }
 
4731
 
 
4732
        if (m_pRDF != NULL)
 
4733
        {
 
4734
                for (z=0;z<g_iCDFChannels;z++)
 
4735
                {
 
4736
                        if (m_pRDF[z] != NULL)
 
4737
                        {
 
4738
                                delete m_pRDF[z];
 
4739
                                m_pRDF[z] = NULL;
 
4740
                        }
 
4741
                }
 
4742
                delete[] m_pRDF;
 
4743
                m_pRDF = NULL;
 
4744
        }
 
4745
        if (m_pADF != NULL)
 
4746
        {
 
4747
                for (z=0;z<g_iCDFChannels;z++)
 
4748
                {
 
4749
                        if (m_pADF[z] != NULL)
 
4750
                        {
 
4751
                                delete m_pADF[z];
 
4752
                                m_pADF[z] = NULL;
 
4753
                        }
 
4754
                }
 
4755
                delete[] m_pADF;
 
4756
                m_pADF = NULL;
 
4757
        }
 
4758
        if (m_pDDF != NULL)
 
4759
        {
 
4760
                for (z=0;z<g_iCDFChannels;z++)
 
4761
                {
 
4762
                        if (m_pDDF[z] != NULL)
 
4763
                        {
 
4764
                                delete m_pDDF[z];
 
4765
                                m_pDDF[z] = NULL;
 
4766
                        }
 
4767
                }
 
4768
                delete[] m_pDDF;
 
4769
                m_pDDF = NULL;
 
4770
        }
 
4771
        if (m_pDipDF != NULL)
 
4772
        {
 
4773
                for (z=0;z<g_iCDFChannels;z++)
 
4774
                {
 
4775
                        if (m_pDipDF[z] != NULL)
 
4776
                        {
 
4777
                                delete m_pDipDF[z];
 
4778
                                m_pDipDF[z] = NULL;
 
4779
                        }
 
4780
                }
 
4781
                delete[] m_pDipDF;
 
4782
                m_pDipDF = NULL;
 
4783
        }
 
4784
        if (m_pVDF != NULL)
 
4785
        {
 
4786
                for (z=0;z<g_iCDFChannels;z++)
 
4787
                {
 
4788
                        if (m_pVDF[z] != NULL)
 
4789
                        {
 
4790
                                delete m_pVDF[z];
 
4791
                                m_pVDF[z] = NULL;
 
4792
                        }
 
4793
                }
 
4794
                delete[] m_pVDF;
 
4795
                m_pVDF = NULL;
 
4796
        }
 
4797
}
 
4798
 
 
4799
 
 
4800
void CSingleMolecule::BuildAtomCodes()
 
4801
{
 
4802
        int z, z2, c1, c2, i;
 
4803
        double ac;
 
4804
        CMolAtom *ma;
 
4805
 
 
4806
        // Die Anfangswerte der AtomCodes: [Ordnungszahl] * 10.0 + [Zahl der Nicht-Wasserstoff-Bindungen]
 
4807
        for (z=0;z<m_oaMolAtoms.GetSize();z++)
 
4808
        {
 
4809
                ma = (CMolAtom*)m_oaMolAtoms[z];
 
4810
                ma->m_fAtomCode = 10.0 * ((CAtom*)g_oaAtoms[m_baAtomIndex[ma->m_iType]])->m_pElement->m_fMass;
 
4811
 
 
4812
                i = 0;
 
4813
                for (z2=0;z2<ma->m_oaBonds.GetSize();z2++)
 
4814
                {
 
4815
                        // Alle Wasserstoff-Atome ueberspringen
 
4816
                        if (((CAtom*)g_oaAtoms[m_baAtomIndex[((CMolAtom*)ma->m_oaBonds[z2])->m_iType]])->m_pElement->m_fMass < 4.5)
 
4817
                                continue;
 
4818
                        ma->m_fAtomCode++;
 
4819
                        i++;
 
4820
                }
 
4821
 
 
4822
                if (g_bVerbose)
 
4823
                        mprintf("    Atom %d (%s%d): 10.0 * %.2f + %d = %.2f\n",z+1,((CAtom*)g_oaAtoms[m_baAtomIndex[ma->m_iType]])->m_sName,ma->m_iOffset+1,((CAtom*)g_oaAtoms[m_baAtomIndex[ma->m_iType]])->m_pElement->m_fMass,i,ma->m_fAtomCode);
 
4824
        }
 
4825
 
 
4826
        i = 0;
 
4827
        do {
 
4828
                c1 = CountDifferentAtomCodes();
 
4829
 
 
4830
                if (g_bVerbose)
 
4831
                        mprintf(WHITE,"\n  Cycle %d: %d different atom codes exist.\n\n",i+1,c1);
 
4832
 
 
4833
                for (z=0;z<m_oaMolAtoms.GetSize();z++)
 
4834
                {
 
4835
                        ma = (CMolAtom*)m_oaMolAtoms[z];
 
4836
                        ma->m_fTempAtomCode = ma->m_fAtomCode * 5.0;
 
4837
 
 
4838
                        for (z2=0;z2<ma->m_oaBonds.GetSize();z2++)
 
4839
                                ma->m_fTempAtomCode += ((CMolAtom*)ma->m_oaBonds[z2])->m_fAtomCode;
 
4840
                }
 
4841
                for (z=0;z<m_oaMolAtoms.GetSize();z++)
 
4842
                {
 
4843
                        ma = (CMolAtom*)m_oaMolAtoms[z];
 
4844
                        ma->m_fAtomCode = ma->m_fTempAtomCode;
 
4845
 
 
4846
                        if (g_bVerbose)
 
4847
                                mprintf("    Atom %d (%s%d): %.2f\n",z+1,((CAtom*)g_oaAtoms[m_baAtomIndex[ma->m_iType]])->m_sName,ma->m_iOffset+1,ma->m_fAtomCode);
 
4848
                }
 
4849
                c2 = CountDifferentAtomCodes();
 
4850
                i++;
 
4851
//              mprintf("Iteration %d: %d classes before, %d classes after.\n",i,c1,c2);
 
4852
        } while (c1 != c2);
 
4853
 
 
4854
        if (g_bVerbose)
 
4855
                mprintf(WHITE,"\nSorting...\n");
 
4856
 
 
4857
        m_iAtomClasses = c2;
 
4858
//      mprintf("Finished.\n");
 
4859
//      mprintf("%d Iterations, %d atom classes found.\n",i,c2);
 
4860
//      mprintf("Sorting Atom Codes...");
 
4861
 
 
4862
        // Sortieren mittels StackSort
 
4863
        for (z=0;z<m_oaMolAtoms.GetSize();z++)
 
4864
        {
 
4865
                ac = -1;
 
4866
                i = -1;
 
4867
                for (z2=z;z2<m_oaMolAtoms.GetSize();z2++)
 
4868
                {
 
4869
                        if (((CMolAtom*)m_oaMolAtoms[z2])->m_fAtomCode > ac)
 
4870
                        {
 
4871
                                ac = ((CMolAtom*)m_oaMolAtoms[z2])->m_fAtomCode;
 
4872
                                i = z2;
 
4873
                        }
 
4874
                }
 
4875
                if (i != -1)
 
4876
                {
 
4877
                        ma = (CMolAtom*)m_oaMolAtoms[z];
 
4878
                        m_oaMolAtoms[z] = m_oaMolAtoms[i];
 
4879
                        m_oaMolAtoms[i] = ma;
 
4880
                        ((CMolAtom*)m_oaMolAtoms[z])->m_iMolAtomNumber = z;
 
4881
                } else
 
4882
                {
 
4883
                        eprintf("CSingleMolecule::BuildAtomCodes(): Weird error.\n");
 
4884
                        return;
 
4885
                }
 
4886
        }
 
4887
 
 
4888
        if (g_bVerbose)
 
4889
        {
 
4890
                for (z=0;z<m_oaMolAtoms.GetSize();z++)
 
4891
                {
 
4892
                        ma = (CMolAtom*)m_oaMolAtoms[z];
 
4893
                        mprintf("    Atom %d (%s%d): %.2f\n",z+1,((CAtom*)g_oaAtoms[m_baAtomIndex[ma->m_iType]])->m_sName,ma->m_iOffset+1,ma->m_fAtomCode);
 
4894
                }
 
4895
                mprintf(WHITE,"Finished.\n\n");
 
4896
        }
 
4897
//      mprintf("Finished.\n");
 
4898
}
 
4899
 
 
4900
 
 
4901
int CSingleMolecule::CountDifferentAtomCodes()
 
4902
{
 
4903
        int z, z2, i;
 
4904
        double *d;
 
4905
 
 
4906
        try { d = new double[m_oaMolAtoms.GetSize()]; } catch(...) { d = NULL; }
 
4907
        if (d == NULL) NewException((double)m_oaMolAtoms.GetSize()*sizeof(double),__FILE__,__LINE__,__PRETTY_FUNCTION__);
 
4908
        
 
4909
        i = 0;
 
4910
        for (z=0;z<m_oaMolAtoms.GetSize();z++)
 
4911
        {
 
4912
                for (z2=0;z2<i;z2++)
 
4913
                        if (d[z2] == ((CMolAtom*)m_oaMolAtoms[z])->m_fAtomCode)
 
4914
                                goto _next;
 
4915
                d[i] = ((CMolAtom*)m_oaMolAtoms[z])->m_fAtomCode;
 
4916
                i++;
 
4917
_next:;
 
4918
        }
 
4919
        delete[] d;
 
4920
        return i;
 
4921
}
 
4922
 
 
4923
 
 
4924
void CMSD::Parse()
 
4925
{
 
4926
        char buf[256];
 
4927
        int ti;
 
4928
//      float tf;
 
4929
 
 
4930
        BTIN;
 
4931
 
 
4932
        try { m_pMSD = new CAF(); } catch(...) { m_pMSD = NULL; }
 
4933
        if (m_pMSD == NULL) NewException((double)sizeof(CAF),__FILE__,__LINE__,__PRETTY_FUNCTION__);
 
4934
        
 
4935
        mprintf(WHITE,"\n*** Mean Square Displacement\n\n");
 
4936
 
 
4937
        try { m_pAtomGroup = new CAtomGroup(); } catch(...) { m_pAtomGroup = NULL; }
 
4938
        if (m_pAtomGroup == NULL) NewException((double)sizeof(CAtomGroup),__FILE__,__LINE__,__PRETTY_FUNCTION__);
 
4939
        
 
4940
_rdfatom1:
 
4941
        mprintf("    Which atom(s) to take from OM %s (e.g. \"C1,C3-5,H\", \"*\"=all)? [#2] ",((CMolecule*)g_oaMolecules[m_iShowMol])->m_sName);
 
4942
        inpprintf("! Which atom(s) to take from OM %s (e.g. \"C1,C3-5,H\", \"*\"=all)? [#2]\n",((CMolecule*)g_oaMolecules[m_iShowMol])->m_sName);
 
4943
        myget(buf);
 
4944
        if (strlen(buf) == 0)
 
4945
        {
 
4946
                if (!m_pAtomGroup->ParseAtoms((CMolecule*)g_oaMolecules[m_iShowMol],"#2"))
 
4947
                {
 
4948
                        eprintf("Weird error.\n");
 
4949
                        inpprintf("! Weird error.\n");
 
4950
                        goto _rdfatom1;
 
4951
                }
 
4952
        } else if (!m_pAtomGroup->ParseAtoms((CMolecule*)g_oaMolecules[m_iShowMol],buf))
 
4953
        {
 
4954
                eprintf("Wrong input.\n");
 
4955
                inpprintf("! Wrong input.\n");
 
4956
                goto _rdfatom1;
 
4957
        }
 
4958
 
 
4959
//_depth:
 
4960
        if (g_iTrajSteps != -1)
 
4961
                m_iResolution = AskUnsignedInteger("    Enter the resolution (=depth) for this MSD (in time steps): [%d] ",int(g_iTrajSteps*0.75),int(g_iTrajSteps*0.75));
 
4962
                        else m_iResolution = AskUnsignedInteger("    Enter the resolution (=depth) for this MSD (in time steps): [10000] ",10000);
 
4963
 
 
4964
        m_iShowAtoms = m_pAtomGroup->m_iAtomGes;
 
4965
 
 
4966
/*      if (g_iTrajSteps != -1)
 
4967
        {
 
4968
                if (g_bMSDCacheMode)
 
4969
                {
 
4970
                        tf = g_iTrajSteps*m_pAtomGroup->m_iAtomGes*((CMolecule*)g_oaMolecules[m_iShowMol])->m_laSingleMolIndex.GetSize()*3.0f*sizeof(float)/1024.0f/1024.0f;
 
4971
                        if (tf >= 10.0f)
 
4972
                                if (!AskYesNo("    This will occupy %.0f MB RAM (once, not for every MSD!). Continue (y/n)? [yes] ",true,tf))
 
4973
                                        goto _depth;
 
4974
                } else
 
4975
                {
 
4976
                        tf = m_iResolution*g_iGesVirtAtomCount*12.0f*sizeof(double)/1024.0f/1024.0f;
 
4977
                        if (tf >= 10.0f)
 
4978
                                if (!AskYesNo("    This will occupy %.0f MB RAM (once, not for every MSD!). Continue (y/n)? [yes] ",true,tf))
 
4979
                                        goto _depth;
 
4980
                }
 
4981
        }*/
 
4982
/*      if (m_iResolution > g_iMaxMSDDepth)
 
4983
                g_iMaxMSDDepth = m_iReolution;*/
 
4984
 
 
4985
        ti = m_iResolution / 1000;
 
4986
        if (ti < 1)
 
4987
                ti = 1;
 
4988
        m_iStride = AskUnsignedInteger("    Take every n-th step for the time axis of the MSD: [%d] ",ti,ti);
 
4989
        m_iStride2 = AskUnsignedInteger("    Shift correlation window n time steps at once: [%d] ",m_iStride,m_iStride);
 
4990
 
 
4991
        if (g_bAdvanced2)
 
4992
        {
 
4993
                m_bSplit = AskYesNo("    Decompose this MSD into contributions from each individual molecule (y/n)? [no] ",false);
 
4994
                if (AskYesNo("    Take into account only certain dimensions for displacement (y/n)? [no] ",false))
 
4995
                {
 
4996
                        m_bTakeX = AskYesNo("      Take into account contributions along X axis (y/n)? [yes] ",true);
 
4997
                        m_bTakeY = AskYesNo("      Take into account contributions along X axis (y/n)? [yes] ",true);
 
4998
                        m_bTakeZ = AskYesNo("      Take into account contributions along X axis (y/n)? [yes] ",true);
 
4999
                } else
 
5000
                {
 
5001
                        m_bTakeX = true;
 
5002
                        m_bTakeY = true;
 
5003
                        m_bTakeZ = true;
 
5004
                }
 
5005
        } else
 
5006
        {
 
5007
                m_bSplit = false;
 
5008
                m_bTakeX = true;
 
5009
                m_bTakeY = true;
 
5010
                m_bTakeZ = true;
 
5011
        }
 
5012
 
 
5013
        BuildName();
 
5014
        BTOUT;
 
5015
}
 
5016
 
 
5017
 
 
5018
void CMSD::BuildName()
 
5019
{
 
5020
        BTIN;
 
5021
        char tmp[256];
 
5022
 
 
5023
        sprintf(tmp,"%s_%s",((CMolecule*)g_oaMolecules[m_iShowMol])->m_sName,m_pAtomGroup->m_sName);
 
5024
 
 
5025
        if ((!m_bTakeX) || (!m_bTakeY) || (!m_bTakeZ))
 
5026
        {
 
5027
                strcat(tmp,"_");
 
5028
                if (m_bTakeX)
 
5029
                        strcat(tmp,"X");
 
5030
                if (m_bTakeY)
 
5031
                        strcat(tmp,"Y");
 
5032
                if (m_bTakeZ)
 
5033
                        strcat(tmp,"Z");
 
5034
        }
 
5035
 
 
5036
        try { m_sName = new char[strlen(tmp)+1]; } catch(...) { m_sName = NULL; }
 
5037
        if (m_sName == NULL) NewException((double)(strlen(tmp)+1)*sizeof(char),__FILE__,__LINE__,__PRETTY_FUNCTION__);
 
5038
        
 
5039
        strcpy(m_sName,tmp);
 
5040
        BTOUT;
 
5041
}
 
5042
 
 
5043
 
 
5044
void CVHDF::CorrectCount()
 
5045
{
 
5046
        int x, y;
 
5047
 
 
5048
        for (y=0;y<m_iResolution;y++)
 
5049
                for (x=0;x<m_iDepth/m_iStride;x++)
 
5050
                        if (m_pCount[x] != 0)
 
5051
                                m_pVHDF->m_pBin[y*m_iDepth/m_iStride+x] /= m_pCount[x];
 
5052
}
 
5053
 
 
5054
 
 
5055
void CConditionSubGroup::PrintData()
 
5056
{
 
5057
        int z;
 
5058
        double d;
 
5059
 
 
5060
        mprintf(GREEN,"\n*** Data for %d. set of conditions ***\n\n",m_iNumber+1);
 
5061
        mprintf("    %.0f of %.0f molecules passed this set of conditions (%.4f percent).\n",m_fPassed,m_fTotal,ZeroDivide(m_fPassed,m_fTotal)*100.0f);
 
5062
        d = 1.0;
 
5063
        for (z=0;z<m_oaConditions.GetSize();z++)
 
5064
        {
 
5065
                mprintf("      - Condition %d: %.0f of %.0f molecules passed (%.4f percent).\n",z+1,((CNbSearch*)m_oaConditions[z])->m_fMoleculesPassed,((CNbSearch*)m_oaConditions[z])->m_fMoleculesTotal,ZeroDivide(((CNbSearch*)m_oaConditions[z])->m_fMoleculesPassed,((CNbSearch*)m_oaConditions[z])->m_fMoleculesTotal)*100.0);
 
5066
                d *= ZeroDivide(((CNbSearch*)m_oaConditions[z])->m_fMoleculesPassed,((CNbSearch*)m_oaConditions[z])->m_fMoleculesTotal);
 
5067
        }
 
5068
        mprintf("\n");
 
5069
        if (m_oaConditions.GetSize() > 1)
 
5070
        {
 
5071
                mprintf("    The product of the condition probabilities is %.4f percent.\n",d*100.0);
 
5072
                mprintf("    If the conditions would be uncorrelated, this would be also the probability for the set.\n");
 
5073
                mprintf("    Therefore, the conditions are %s correlated for %.4f percent.\n\n",(d<ZeroDivide(m_fPassed,m_fTotal))?"positively":"negatively",(d<ZeroDivide(m_fPassed,m_fTotal))?(ZeroDivide(ZeroDivide(m_fPassed,m_fTotal),d)-1.0)*100.0:(ZeroDivide(d,ZeroDivide(m_fPassed,m_fTotal))-1.0)*100.0);
 
5074
        }
 
5075
 
 
5076
        for (z=0;z<m_oaConditions.GetSize();z++)
 
5077
                ((CNbSearch*)m_oaConditions[z])->PrintTable();
 
5078
}
 
5079
 
 
5080
 
 
5081
void CConditionSubGroup::PrintData(FILE *a)
 
5082
{
 
5083
        int z;
 
5084
 
 
5085
        mfprintf(a,"\n*** Data for %d. set of conditions ***\n\n",m_iNumber+1);
 
5086
        mfprintf(a,"    %.0f of %.0f molecules passed this set of conditions (%.4f percent).\n",m_fPassed,m_fTotal,ZeroDivide(m_fPassed,m_fTotal)*100.0f);
 
5087
        for (z=0;z<m_oaConditions.GetSize();z++)
 
5088
                ((CNbSearch*)m_oaConditions[z])->PrintTable(a);
 
5089
}
 
5090
 
 
5091
 
 
5092
void CConditionSubGroup::PrintSingle(int om)
 
5093
{
 
5094
        int z;
 
5095
 
 
5096
        for (z=0;z<m_oaConditions.GetSize();z++)
 
5097
                ((CNbSearch*)m_oaConditions[z])->PrintSingle(om);
 
5098
}
 
5099
 
 
5100
 
 
5101
void CConditionGroup::PrintSingle(int om)
 
5102
{
 
5103
        int z;
 
5104
 
 
5105
        for (z=0;z<m_oaConditionSubGroups.GetSize();z++)
 
5106
                ((CConditionSubGroup*)m_oaConditionSubGroups[z])->PrintSingle(om);
 
5107
}
 
5108
 
 
5109
 
 
5110
void CConditionGroup::PrintTable()
 
5111
{
 
5112
        int z, z2;
 
5113
        double tf1, tf2, tf3;
 
5114
 
 
5115
        mprintf(WHITE,"*** Condition Table ***\n\n");
 
5116
        mprintf("    The rows indicate how many subconditions of condition 1 are fulfilled.\n");
 
5117
        mprintf("    The columns indicate how many subconditions of condition 2 are fulfilled.\n\n");
 
5118
 
 
5119
        mprintf("     ");
 
5120
        for (z=0;z<((CConditionSubGroup*)m_oaConditionSubGroups[1])->m_iCombinations+1;z++)
 
5121
                mprintf("| %4d    ",z);
 
5122
        mprintf("\n");
 
5123
        mprintf("-----");
 
5124
        for (z=0;z<((CConditionSubGroup*)m_oaConditionSubGroups[1])->m_iCombinations+1;z++)
 
5125
                mprintf("|---------",z);
 
5126
        mprintf("\n");
 
5127
        tf1 = 0;
 
5128
        tf2 = 0;
 
5129
        tf3 = 0;
 
5130
        for (z=0;z<((CConditionSubGroup*)m_oaConditionSubGroups[0])->m_iCombinations+1;z++)
 
5131
        {
 
5132
                mprintf(" %3d ",z);
 
5133
                for (z2=0;z2<((CConditionSubGroup*)m_oaConditionSubGroups[1])->m_iCombinations+1;z2++)
 
5134
                {
 
5135
                        if ((z > 0) && (z2 == 0))
 
5136
                                tf1 += m_pTable[z*(((CConditionSubGroup*)m_oaConditionSubGroups[1])->m_iCombinations+1)+z2];
 
5137
                        if ((z == 0) && (z2 > 0))
 
5138
                                tf2 += m_pTable[z*(((CConditionSubGroup*)m_oaConditionSubGroups[1])->m_iCombinations+1)+z2];
 
5139
                        if ((z > 0) && (z2 > 0))
 
5140
                                tf3 += m_pTable[z*(((CConditionSubGroup*)m_oaConditionSubGroups[1])->m_iCombinations+1)+z2];
 
5141
                        mprintf("| %7.3f ",m_pTable[z*(((CConditionSubGroup*)m_oaConditionSubGroups[1])->m_iCombinations+1)+z2]/m_fTableGes*100.0);
 
5142
                }
 
5143
                mprintf("\n");
 
5144
        }
 
5145
        mprintf("\n");
 
5146
        mprintf("    A RM/OM pair fulfills no condition:      %7.3f percent of the time.\n",m_pTable[0]/m_fTableGes*100.0);
 
5147
        mprintf("    A RM/OM pair fulfills only condition 1:  %7.3f percent of the time.\n",tf1/m_fTableGes*100.0);
 
5148
        mprintf("    A RM/OM pair fulfills only condition 2:  %7.3f percent of the time.\n",tf2/m_fTableGes*100.0);
 
5149
        mprintf("    A RM/OM pair fulfills both conditions:   %7.3f percent of the time.\n",tf3/m_fTableGes*100.0);
 
5150
        mprintf("                                    Total:   %7.3f percent of the time.\n",100.0);
 
5151
        mprintf("\n");
 
5152
        mprintf(WHITE,"*** Condition Table End ***\n\n");
 
5153
}
 
5154
 
 
5155
 
 
5156
void CObservation::ListCDFObservations(int z)
 
5157
{
 
5158
        int z2, ti, ti2, ti3;
 
5159
        CxIntArray tempwa;
 
5160
 
 
5161
        switch(g_iObsChannel[z])
 
5162
        {
 
5163
                case 0: // RDF
 
5164
                        if (m_bOthers)
 
5165
                        {
 
5166
                                if (m_bSecondShowMol && (z == 1))
 
5167
                                        m_pRDF[z]->BuildAtomList((CSingleMolecule*)g_oaSingleMolecules[((CMolecule*)g_oaMolecules[g_iFixMol])->m_laSingleMolIndex[0]],(CSingleMolecule*)g_oaSingleMolecules[((CMolecule*)g_oaMolecules[m_iShowMol2])->m_laSingleMolIndex[0]],&tempwa);
 
5168
                                                else m_pRDF[z]->BuildAtomList((CSingleMolecule*)g_oaSingleMolecules[((CMolecule*)g_oaMolecules[g_iFixMol])->m_laSingleMolIndex[0]],(CSingleMolecule*)g_oaSingleMolecules[((CMolecule*)g_oaMolecules[m_iShowMol])->m_laSingleMolIndex[0]],&tempwa);
 
5169
                        } else m_pRDF[z]->BuildAtomList((CSingleMolecule*)g_oaSingleMolecules[((CMolecule*)g_oaMolecules[g_iFixMol])->m_laSingleMolIndex[0]],(CSingleMolecule*)g_oaSingleMolecules[((CMolecule*)g_oaMolecules[g_iFixMol])->m_laSingleMolIndex[0]],&tempwa);
 
5170
                        for (z2=0;z2<tempwa.GetSize()/2;z2++)
 
5171
                        {
 
5172
                                ti = tempwa[z2*2];
 
5173
                                ti2 = tempwa[z2*2+1];
 
5174
                                mprintf("  * %2d.) Distance %s%d (%s) <--> %s%d (%s)\n",z2+1,((CAtom*)g_oaAtoms[g_waAtomRealElement[ti]])->m_sName,g_waAtomMolNumber[ti]+1,((CMolecule*)g_oaMolecules[g_waAtomMolIndex[ti]])->m_sName,((CAtom*)g_oaAtoms[g_waAtomRealElement[ti2]])->m_sName,g_waAtomMolNumber[ti2]+1,((CMolecule*)g_oaMolecules[g_waAtomMolIndex[ti2]])->m_sName);
 
5175
                        }
 
5176
                        break;
 
5177
 
 
5178
                case 1: // ADF
 
5179
                        if (m_bOthers)
 
5180
                        {
 
5181
                                if (m_bSecondShowMol && (z == 1))
 
5182
                                        m_pADF[z]->BuildAtomList((CSingleMolecule*)g_oaSingleMolecules[((CMolecule*)g_oaMolecules[g_iFixMol])->m_laSingleMolIndex[0]],(CSingleMolecule*)g_oaSingleMolecules[((CMolecule*)g_oaMolecules[m_iShowMol2])->m_laSingleMolIndex[0]],&tempwa);
 
5183
                                                else m_pADF[z]->BuildAtomList((CSingleMolecule*)g_oaSingleMolecules[((CMolecule*)g_oaMolecules[g_iFixMol])->m_laSingleMolIndex[0]],(CSingleMolecule*)g_oaSingleMolecules[((CMolecule*)g_oaMolecules[m_iShowMol])->m_laSingleMolIndex[0]],&tempwa);
 
5184
                        } else m_pADF[z]->BuildAtomList((CSingleMolecule*)g_oaSingleMolecules[((CMolecule*)g_oaMolecules[g_iFixMol])->m_laSingleMolIndex[0]],(CSingleMolecule*)g_oaSingleMolecules[((CMolecule*)g_oaMolecules[g_iFixMol])->m_laSingleMolIndex[0]],&tempwa);
 
5185
                        for (z2=0;z2<tempwa.GetSize()/6;z2++)
 
5186
                        {
 
5187
                                mprintf("  * %2d.) Angle ",z2+1);
 
5188
                                if (m_pADF[z]->m_bOrtho[0])
 
5189
                                {
 
5190
                                        ti = tempwa[z2*6];
 
5191
                                        ti2 = tempwa[z2*6+1];
 
5192
                                        ti3 = tempwa[z2*6+2];
 
5193
                                        mprintf("[%s%d (%s), %s%d (%s), %s%d (%s)] to ",((CAtom*)g_oaAtoms[g_waAtomRealElement[ti]])->m_sName,g_waAtomMolNumber[ti]+1,((CMolecule*)g_oaMolecules[g_waAtomMolIndex[ti]])->m_sName,((CAtom*)g_oaAtoms[g_waAtomRealElement[ti2]])->m_sName,g_waAtomMolNumber[ti2]+1,((CMolecule*)g_oaMolecules[g_waAtomMolIndex[ti2]])->m_sName,((CAtom*)g_oaAtoms[g_waAtomRealElement[ti3]])->m_sName,g_waAtomMolNumber[ti3]+1,((CMolecule*)g_oaMolecules[g_waAtomMolIndex[ti3]])->m_sName);
 
5194
                                } else
 
5195
                                {
 
5196
                                        ti = tempwa[z2*6];
 
5197
                                        ti2 = tempwa[z2*6+1];
 
5198
                                        mprintf("[%s%d (%s) --> %s%d (%s)] to ",((CAtom*)g_oaAtoms[g_waAtomRealElement[ti]])->m_sName,g_waAtomMolNumber[ti]+1,((CMolecule*)g_oaMolecules[g_waAtomMolIndex[ti]])->m_sName,((CAtom*)g_oaAtoms[g_waAtomRealElement[ti2]])->m_sName,g_waAtomMolNumber[ti2]+1,((CMolecule*)g_oaMolecules[g_waAtomMolIndex[ti2]])->m_sName);
 
5199
                                }
 
5200
                                if (m_pADF[z]->m_bOrtho[1])
 
5201
                                {
 
5202
                                        ti = tempwa[z2*6+3];
 
5203
                                        ti2 = tempwa[z2*6+4];
 
5204
                                        ti3 = tempwa[z2*6+5];
 
5205
                                        mprintf("[%s%d (%s), %s%d (%s), %s%d (%s)]\n",((CAtom*)g_oaAtoms[g_waAtomRealElement[ti]])->m_sName,g_waAtomMolNumber[ti]+1,((CMolecule*)g_oaMolecules[g_waAtomMolIndex[ti]])->m_sName,((CAtom*)g_oaAtoms[g_waAtomRealElement[ti2]])->m_sName,g_waAtomMolNumber[ti2]+1,((CMolecule*)g_oaMolecules[g_waAtomMolIndex[ti2]])->m_sName,((CAtom*)g_oaAtoms[g_waAtomRealElement[ti3]])->m_sName,g_waAtomMolNumber[ti3]+1,((CMolecule*)g_oaMolecules[g_waAtomMolIndex[ti3]])->m_sName);
 
5206
                                } else
 
5207
                                {
 
5208
                                        ti = tempwa[z2*6+3];
 
5209
                                        ti2 = tempwa[z2*6+4];
 
5210
                                        mprintf("[%s%d (%s) --> %s%d (%s)]\n",((CAtom*)g_oaAtoms[g_waAtomRealElement[ti]])->m_sName,g_waAtomMolNumber[ti]+1,((CMolecule*)g_oaMolecules[g_waAtomMolIndex[ti]])->m_sName,((CAtom*)g_oaAtoms[g_waAtomRealElement[ti2]])->m_sName,g_waAtomMolNumber[ti2]+1,((CMolecule*)g_oaMolecules[g_waAtomMolIndex[ti2]])->m_sName);
 
5211
                                }
 
5212
                        }
 
5213
                        break;
 
5214
 
 
5215
                case 2: // DDF
 
5216
                        if (m_bOthers)
 
5217
                        {
 
5218
                                if (m_bSecondShowMol && (z == 1))
 
5219
                                        m_pDDF[z]->BuildAtomList((CSingleMolecule*)g_oaSingleMolecules[((CMolecule*)g_oaMolecules[g_iFixMol])->m_laSingleMolIndex[0]],(CSingleMolecule*)g_oaSingleMolecules[((CMolecule*)g_oaMolecules[m_iShowMol2])->m_laSingleMolIndex[0]],&tempwa);
 
5220
                                                else m_pDDF[z]->BuildAtomList((CSingleMolecule*)g_oaSingleMolecules[((CMolecule*)g_oaMolecules[g_iFixMol])->m_laSingleMolIndex[0]],(CSingleMolecule*)g_oaSingleMolecules[((CMolecule*)g_oaMolecules[m_iShowMol])->m_laSingleMolIndex[0]],&tempwa);
 
5221
                        } else m_pDDF[z]->BuildAtomList((CSingleMolecule*)g_oaSingleMolecules[((CMolecule*)g_oaMolecules[g_iFixMol])->m_laSingleMolIndex[0]],(CSingleMolecule*)g_oaSingleMolecules[((CMolecule*)g_oaMolecules[g_iFixMol])->m_laSingleMolIndex[0]],&tempwa);
 
5222
                        for (z2=0;z2<tempwa.GetSize()/9;z2++)
 
5223
                        {
 
5224
                                mprintf("  * %2d.) Dihedral Angle ",z2+1);
 
5225
                                if (m_pDDF[z]->m_bOrtho[0])
 
5226
                                {
 
5227
                                        ti = tempwa[z2*9];
 
5228
                                        ti2 = tempwa[z2*9+1];
 
5229
                                        ti3 = tempwa[z2*9+2];
 
5230
                                        mprintf("[%s%d (%s), %s%d (%s), %s%d (%s)] - ",((CAtom*)g_oaAtoms[g_waAtomRealElement[ti]])->m_sName,g_waAtomMolNumber[ti]+1,((CMolecule*)g_oaMolecules[g_waAtomMolIndex[ti]])->m_sName,((CAtom*)g_oaAtoms[g_waAtomRealElement[ti2]])->m_sName,g_waAtomMolNumber[ti2]+1,((CMolecule*)g_oaMolecules[g_waAtomMolIndex[ti2]])->m_sName,((CAtom*)g_oaAtoms[g_waAtomRealElement[ti3]])->m_sName,g_waAtomMolNumber[ti3]+1,((CMolecule*)g_oaMolecules[g_waAtomMolIndex[ti3]])->m_sName);
 
5231
                                } else
 
5232
                                {
 
5233
                                        ti = tempwa[z2*9];
 
5234
                                        ti2 = tempwa[z2*9+1];
 
5235
                                        mprintf("[%s%d (%s) --> %s%d (%s)] - ",((CAtom*)g_oaAtoms[g_waAtomRealElement[ti]])->m_sName,g_waAtomMolNumber[ti]+1,((CMolecule*)g_oaMolecules[g_waAtomMolIndex[ti]])->m_sName,((CAtom*)g_oaAtoms[g_waAtomRealElement[ti2]])->m_sName,g_waAtomMolNumber[ti2]+1,((CMolecule*)g_oaMolecules[g_waAtomMolIndex[ti2]])->m_sName);
 
5236
                                }
 
5237
                                if (m_pDDF[z]->m_bOrtho[1])
 
5238
                                {
 
5239
                                        ti = tempwa[z2*9+3];
 
5240
                                        ti2 = tempwa[z2*9+4];
 
5241
                                        ti3 = tempwa[z2*9+5];
 
5242
                                        mprintf("[%s%d (%s), %s%d (%s), %s%d (%s)] - ",((CAtom*)g_oaAtoms[g_waAtomRealElement[ti]])->m_sName,g_waAtomMolNumber[ti]+1,((CMolecule*)g_oaMolecules[g_waAtomMolIndex[ti]])->m_sName,((CAtom*)g_oaAtoms[g_waAtomRealElement[ti2]])->m_sName,g_waAtomMolNumber[ti2]+1,((CMolecule*)g_oaMolecules[g_waAtomMolIndex[ti2]])->m_sName,((CAtom*)g_oaAtoms[g_waAtomRealElement[ti3]])->m_sName,g_waAtomMolNumber[ti3]+1,((CMolecule*)g_oaMolecules[g_waAtomMolIndex[ti3]])->m_sName);
 
5243
                                } else
 
5244
                                {
 
5245
                                        ti = tempwa[z2*9+3];
 
5246
                                        ti2 = tempwa[z2*9+4];
 
5247
                                        mprintf("[%s%d (%s) --> %s%d (%s)] - ",((CAtom*)g_oaAtoms[g_waAtomRealElement[ti]])->m_sName,g_waAtomMolNumber[ti]+1,((CMolecule*)g_oaMolecules[g_waAtomMolIndex[ti]])->m_sName,((CAtom*)g_oaAtoms[g_waAtomRealElement[ti2]])->m_sName,g_waAtomMolNumber[ti2]+1,((CMolecule*)g_oaMolecules[g_waAtomMolIndex[ti2]])->m_sName);
 
5248
                                }
 
5249
                                if (m_pDDF[z]->m_bOrtho[2])
 
5250
                                {
 
5251
                                        ti = tempwa[z2*9+6];
 
5252
                                        ti2 = tempwa[z2*9+7];
 
5253
                                        ti3 = tempwa[z2*9+8];
 
5254
                                        mprintf("[%s%d (%s), %s%d (%s), %s%d (%s)]\n",((CAtom*)g_oaAtoms[g_waAtomRealElement[ti]])->m_sName,g_waAtomMolNumber[ti]+1,((CMolecule*)g_oaMolecules[g_waAtomMolIndex[ti]])->m_sName,((CAtom*)g_oaAtoms[g_waAtomRealElement[ti2]])->m_sName,g_waAtomMolNumber[ti2]+1,((CMolecule*)g_oaMolecules[g_waAtomMolIndex[ti2]])->m_sName,((CAtom*)g_oaAtoms[g_waAtomRealElement[ti3]])->m_sName,g_waAtomMolNumber[ti3]+1,((CMolecule*)g_oaMolecules[g_waAtomMolIndex[ti3]])->m_sName);
 
5255
                                } else
 
5256
                                {
 
5257
                                        ti = tempwa[z2*9+6];
 
5258
                                        ti2 = tempwa[z2*9+7];
 
5259
                                        mprintf("[%s%d (%s) --> %s%d (%s)]\n",((CAtom*)g_oaAtoms[g_waAtomRealElement[ti]])->m_sName,g_waAtomMolNumber[ti]+1,((CMolecule*)g_oaMolecules[g_waAtomMolIndex[ti]])->m_sName,((CAtom*)g_oaAtoms[g_waAtomRealElement[ti2]])->m_sName,g_waAtomMolNumber[ti2]+1,((CMolecule*)g_oaMolecules[g_waAtomMolIndex[ti2]])->m_sName);
 
5260
                                }
 
5261
                        }
 
5262
                        break;
 
5263
 
 
5264
                case 3:
 
5265
                        eprintf("(not implemented)\n");
 
5266
                        break;
 
5267
 
 
5268
                case 4:
 
5269
                        eprintf("(not implemented)\n");
 
5270
                        break;
 
5271
 
 
5272
                case 5: // PlDF
 
5273
                        if (m_bOthers)
 
5274
                        {
 
5275
                                if (m_bSecondShowMol && (z == 1))
 
5276
                                        m_pPlDF[z]->BuildAtomList((CSingleMolecule*)g_oaSingleMolecules[((CMolecule*)g_oaMolecules[g_iFixMol])->m_laSingleMolIndex[0]],(CSingleMolecule*)g_oaSingleMolecules[((CMolecule*)g_oaMolecules[m_iShowMol2])->m_laSingleMolIndex[0]],&tempwa);
 
5277
                                                else m_pPlDF[z]->BuildAtomList((CSingleMolecule*)g_oaSingleMolecules[((CMolecule*)g_oaMolecules[g_iFixMol])->m_laSingleMolIndex[0]],(CSingleMolecule*)g_oaSingleMolecules[((CMolecule*)g_oaMolecules[m_iShowMol])->m_laSingleMolIndex[0]],&tempwa);
 
5278
                        } else m_pPlDF[z]->BuildAtomList((CSingleMolecule*)g_oaSingleMolecules[((CMolecule*)g_oaMolecules[g_iFixMol])->m_laSingleMolIndex[0]],(CSingleMolecule*)g_oaSingleMolecules[((CMolecule*)g_oaMolecules[g_iFixMol])->m_laSingleMolIndex[0]],&tempwa);
 
5279
                        for (z2=0;z2<tempwa.GetSize()/4;z2++)
 
5280
                        {
 
5281
                                mprintf("  * %2d.) Distance from Plane ",z2+1);
 
5282
                                if (m_pPlDF[z]->m_bNormal)
 
5283
                                {
 
5284
                                        ti = tempwa[z2*4];
 
5285
                                        ti2 = tempwa[z2*4+1];
 
5286
                                        mprintf("[%s%d (%s) --> %s%d (%s)] - ",((CAtom*)g_oaAtoms[g_waAtomRealElement[ti]])->m_sName,g_waAtomMolNumber[ti]+1,((CMolecule*)g_oaMolecules[g_waAtomMolIndex[ti]])->m_sName,((CAtom*)g_oaAtoms[g_waAtomRealElement[ti2]])->m_sName,g_waAtomMolNumber[ti2]+1,((CMolecule*)g_oaMolecules[g_waAtomMolIndex[ti2]])->m_sName);
 
5287
                                } else
 
5288
                                {
 
5289
                                        ti = tempwa[z2*4];
 
5290
                                        ti2 = tempwa[z2*4+1];
 
5291
                                        ti3 = tempwa[z2*4+2];
 
5292
                                        mprintf("[%s%d (%s), %s%d (%s), %s%d (%s)] - ",((CAtom*)g_oaAtoms[g_waAtomRealElement[ti]])->m_sName,g_waAtomMolNumber[ti]+1,((CMolecule*)g_oaMolecules[g_waAtomMolIndex[ti]])->m_sName,((CAtom*)g_oaAtoms[g_waAtomRealElement[ti2]])->m_sName,g_waAtomMolNumber[ti2]+1,((CMolecule*)g_oaMolecules[g_waAtomMolIndex[ti2]])->m_sName,((CAtom*)g_oaAtoms[g_waAtomRealElement[ti3]])->m_sName,g_waAtomMolNumber[ti3]+1,((CMolecule*)g_oaMolecules[g_waAtomMolIndex[ti3]])->m_sName);
 
5293
                                }
 
5294
                                ti = tempwa[z2*4+3];
 
5295
                                mprintf("%s%d (%s)\n",((CAtom*)g_oaAtoms[g_waAtomRealElement[ti]])->m_sName,g_waAtomMolNumber[ti]+1,((CMolecule*)g_oaMolecules[g_waAtomMolIndex[ti]])->m_sName);
 
5296
                        }
 
5297
                        break;
 
5298
 
 
5299
                case 6: // LiDF
 
5300
                        if (m_bOthers)
 
5301
                        {
 
5302
                                if (m_bSecondShowMol && (z == 1))
 
5303
                                        m_pLiDF[z]->BuildAtomList((CSingleMolecule*)g_oaSingleMolecules[((CMolecule*)g_oaMolecules[g_iFixMol])->m_laSingleMolIndex[0]],(CSingleMolecule*)g_oaSingleMolecules[((CMolecule*)g_oaMolecules[m_iShowMol2])->m_laSingleMolIndex[0]],&tempwa);
 
5304
                                                else m_pLiDF[z]->BuildAtomList((CSingleMolecule*)g_oaSingleMolecules[((CMolecule*)g_oaMolecules[g_iFixMol])->m_laSingleMolIndex[0]],(CSingleMolecule*)g_oaSingleMolecules[((CMolecule*)g_oaMolecules[m_iShowMol])->m_laSingleMolIndex[0]],&tempwa);
 
5305
                        } else m_pLiDF[z]->BuildAtomList((CSingleMolecule*)g_oaSingleMolecules[((CMolecule*)g_oaMolecules[g_iFixMol])->m_laSingleMolIndex[0]],(CSingleMolecule*)g_oaSingleMolecules[((CMolecule*)g_oaMolecules[g_iFixMol])->m_laSingleMolIndex[0]],&tempwa);
 
5306
                        for (z2=0;z2<tempwa.GetSize()/4;z2++)
 
5307
                        {
 
5308
                                mprintf("  * %2d.) Distance from Plane ",z2+1);
 
5309
                                if (m_pLiDF[z]->m_bNormal)
 
5310
                                {
 
5311
                                        ti = tempwa[z2*4];
 
5312
                                        ti2 = tempwa[z2*4+1];
 
5313
                                        ti3 = tempwa[z2*4+2];
 
5314
                                        mprintf("[%s%d (%s), %s%d (%s), %s%d (%s)] - ",((CAtom*)g_oaAtoms[g_waAtomRealElement[ti]])->m_sName,g_waAtomMolNumber[ti]+1,((CMolecule*)g_oaMolecules[g_waAtomMolIndex[ti]])->m_sName,((CAtom*)g_oaAtoms[g_waAtomRealElement[ti2]])->m_sName,g_waAtomMolNumber[ti2]+1,((CMolecule*)g_oaMolecules[g_waAtomMolIndex[ti2]])->m_sName,((CAtom*)g_oaAtoms[g_waAtomRealElement[ti3]])->m_sName,g_waAtomMolNumber[ti3]+1,((CMolecule*)g_oaMolecules[g_waAtomMolIndex[ti3]])->m_sName);
 
5315
                                } else
 
5316
                                {
 
5317
                                        ti = tempwa[z2*4];
 
5318
                                        ti2 = tempwa[z2*4+1];
 
5319
                                        mprintf("[%s%d (%s) --> %s%d (%s)] - ",((CAtom*)g_oaAtoms[g_waAtomRealElement[ti]])->m_sName,g_waAtomMolNumber[ti]+1,((CMolecule*)g_oaMolecules[g_waAtomMolIndex[ti]])->m_sName,((CAtom*)g_oaAtoms[g_waAtomRealElement[ti2]])->m_sName,g_waAtomMolNumber[ti2]+1,((CMolecule*)g_oaMolecules[g_waAtomMolIndex[ti2]])->m_sName);
 
5320
                                }
 
5321
                                ti = tempwa[z2*4+3];
 
5322
                                mprintf("%s%d (%s)\n",((CAtom*)g_oaAtoms[g_waAtomRealElement[ti]])->m_sName,g_waAtomMolNumber[ti]+1,((CMolecule*)g_oaMolecules[g_waAtomMolIndex[ti]])->m_sName);
 
5323
                        }
 
5324
                        break;
 
5325
        }
 
5326
}
 
5327
 
 
5328
 
 
5329
void CSDF::CreateCutPlane()
 
5330
{
 
5331
        int x, y;
 
5332
        CxVector3 vec;
 
5333
 
 
5334
        try { m_pCutPlane = new C2DF(); } catch(...) { m_pCutPlane = NULL; }
 
5335
        if (m_pCutPlane == NULL) NewException((double)sizeof(C2DF),__FILE__,__LINE__,__PRETTY_FUNCTION__);
 
5336
        
 
5337
        m_pCutPlane->m_fMinVal[0] = -m_fRadius;
 
5338
        m_pCutPlane->m_fMinVal[1] = -m_fRadius;
 
5339
        m_pCutPlane->m_fMaxVal[0] = m_fRadius;
 
5340
        m_pCutPlane->m_fMaxVal[1] = m_fRadius;
 
5341
        m_pCutPlane->m_iRes[0] = m_iCutPlaneResolution;
 
5342
        m_pCutPlane->m_iRes[1] = m_iCutPlaneResolution;
 
5343
        m_pCutPlane->SetLabelX("X [pm]");
 
5344
        m_pCutPlane->SetLabelY("Y [pm]");
 
5345
        m_pCutPlane->Create();
 
5346
 
 
5347
        vec[2] = 0;
 
5348
        for (y=0;y<m_iCutPlaneResolution;y++)
 
5349
        {
 
5350
                vec[1] = (float)(((y+0.5)/m_pCutPlane->m_iRes[1])*(m_pCutPlane->m_fMaxVal[1]-m_pCutPlane->m_fMinVal[1])+m_pCutPlane->m_fMinVal[1]);
 
5351
                for (x=0;x<m_iCutPlaneResolution;x++)
 
5352
                {
 
5353
                        vec[0] = (float)(((x+0.5)/m_pCutPlane->m_iRes[0])*(m_pCutPlane->m_fMaxVal[0]-m_pCutPlane->m_fMinVal[0])+m_pCutPlane->m_fMinVal[0]);
 
5354
                        m_pCutPlane->AddToBin(x,y,m_pSDF->GetValue(vec));
 
5355
                }
 
5356
        }
 
5357
        if (m_bCutPlaneShowAtoms)
 
5358
        {
 
5359
                m_pCutPlane->AddCircle(0,0,((CAtom*)g_oaAtoms[g_iFixRealAtomType[0]])->m_pElement->m_fRadius*0.75,((CAtom*)g_oaAtoms[g_iFixRealAtomType[0]])->m_pElement->m_iColorR/255.0,((CAtom*)g_oaAtoms[g_iFixRealAtomType[0]])->m_pElement->m_iColorG/255.0,((CAtom*)g_oaAtoms[g_iFixRealAtomType[0]])->m_pElement->m_iColorB/255.0);
 
5360
                m_pCutPlane->AddCircle(m_fAtom2PosX / m_fPosCounter,0,((CAtom*)g_oaAtoms[g_iFixRealAtomType[1]])->m_pElement->m_fRadius*0.75,((CAtom*)g_oaAtoms[g_iFixRealAtomType[1]])->m_pElement->m_iColorR/255.0,((CAtom*)g_oaAtoms[g_iFixRealAtomType[1]])->m_pElement->m_iColorG/255.0,((CAtom*)g_oaAtoms[g_iFixRealAtomType[1]])->m_pElement->m_iColorB/255.0);
 
5361
                m_pCutPlane->AddCircle(m_fAtom3PosX / m_fPosCounter,m_fAtom3PosY / m_fPosCounter,((CAtom*)g_oaAtoms[g_iFixRealAtomType[2]])->m_pElement->m_fRadius*0.75,((CAtom*)g_oaAtoms[g_iFixRealAtomType[2]])->m_pElement->m_iColorR/255.0,((CAtom*)g_oaAtoms[g_iFixRealAtomType[2]])->m_pElement->m_iColorG/255.0,((CAtom*)g_oaAtoms[g_iFixRealAtomType[2]])->m_pElement->m_iColorB/255.0);
 
5362
        }
 
5363
}
 
5364
 
 
5365
 
 
5366
void CConditionGroup::Reset()
 
5367
{
 
5368
        int z;
 
5369
 
 
5370
        for (z=0;z<m_oaConditionSubGroups.GetSize();z++)
 
5371
                ((CConditionSubGroup*)m_oaConditionSubGroups[z])->Reset();
 
5372
 
 
5373
        for (z=0;z<((CMolecule*)g_oaMolecules[m_iShowMol])->m_laSingleMolIndex.GetSize();z++)
 
5374
                m_iPassCounter[z] = 0;
 
5375
}
 
5376
 
 
5377
 
 
5378
void CConditionSubGroup::Reset()
 
5379
{
 
5380
        int z;
 
5381
 
 
5382
        for (z=0;z<m_oaConditions.GetSize();z++)
 
5383
                ((CNbSearch*)m_oaConditions[z])->Reset();
 
5384
}
 
5385
 
 
5386
 
 
5387
void CRDF::CopyFrom(CRDF *p)
 
5388
{
 
5389
        int z;
 
5390
        CAtomGroup *ag;
 
5391
 
 
5392
        m_bAdaptive = p->m_bAdaptive;
 
5393
        m_bRadialCorrect = p->m_bRadialCorrect;
 
5394
        m_bSelf = p->m_bSelf;
 
5395
        m_fMinDist = p->m_fMinDist;
 
5396
        m_fMaxDist = p->m_fMaxDist;
 
5397
        m_iCombinations = p->m_iCombinations;
 
5398
        m_iHistogramRes = p->m_iHistogramRes;
 
5399
        m_iRefAtomGes = p->m_iRefAtomGes;
 
5400
        m_iRefOrSec[0] = p->m_iRefOrSec[0];
 
5401
        m_iRefOrSec[1] = p->m_iRefOrSec[1];
 
5402
        m_iResolution = p->m_iResolution;
 
5403
        m_iShowAtomGes = p->m_iShowAtomGes;
 
5404
        m_iShowMol = p->m_iShowMol;
 
5405
 
 
5406
        if (p->m_sName != NULL)
 
5407
        {
 
5408
                try { m_sName = new char[strlen(p->m_sName)+1]; } catch(...) { m_sName = NULL; }
 
5409
                if (m_sName == NULL) NewException((double)(strlen(p->m_sName)+1)*sizeof(char),__FILE__,__LINE__,__PRETTY_FUNCTION__);
 
5410
                
 
5411
                strcpy(m_sName,p->m_sName);
 
5412
        } else m_sName = NULL;
 
5413
 
 
5414
        if (p->m_sShortName != NULL)
 
5415
        {
 
5416
                try { m_sShortName = new char[strlen(p->m_sShortName)+1]; } catch(...) { m_sShortName = NULL; }
 
5417
                if (m_sShortName == NULL) NewException((double)(strlen(p->m_sShortName)+1)*sizeof(char),__FILE__,__LINE__,__PRETTY_FUNCTION__);
 
5418
                
 
5419
                strcpy(m_sShortName,p->m_sShortName);
 
5420
        } else m_sShortName = NULL;
 
5421
 
 
5422
        if (p->m_baDataEnabled != NULL)
 
5423
        {
 
5424
                try { m_baDataEnabled = new CxByteArray[((CMolecule*)g_oaMolecules[m_iShowMol])->m_laSingleMolIndex.GetSize()]; } catch(...) { m_baDataEnabled = NULL; }
 
5425
                if (m_baDataEnabled == NULL) NewException((double)((CMolecule*)g_oaMolecules[m_iShowMol])->m_laSingleMolIndex.GetSize()*sizeof(CxByteArray),__FILE__,__LINE__,__PRETTY_FUNCTION__);
 
5426
                
 
5427
                for (z=0;z<((CMolecule*)g_oaMolecules[m_iShowMol])->m_laSingleMolIndex.GetSize();z++)
 
5428
                        m_baDataEnabled[z].CopyFrom(&p->m_baDataEnabled[z]);
 
5429
        }
 
5430
 
 
5431
        if (p->m_faData != NULL)
 
5432
        {
 
5433
                try { m_faData = new CxDoubleArray[((CMolecule*)g_oaMolecules[m_iShowMol])->m_laSingleMolIndex.GetSize()]; } catch(...) { m_faData = NULL; }
 
5434
                if (m_faData == NULL) NewException((double)((CMolecule*)g_oaMolecules[m_iShowMol])->m_laSingleMolIndex.GetSize()*sizeof(CxDoubleArray),__FILE__,__LINE__,__PRETTY_FUNCTION__);
 
5435
                
 
5436
                for (z=0;z<((CMolecule*)g_oaMolecules[m_iShowMol])->m_laSingleMolIndex.GetSize();z++)
 
5437
                        m_faData[z].CopyFrom(&p->m_faData[z]);
 
5438
        }
 
5439
 
 
5440
        for (z=0;z<p->m_oaVectors.GetSize();z++)
 
5441
        {
 
5442
                try { ag = new CAtomGroup(); } catch(...) { ag = NULL; }
 
5443
                if (ag == NULL) NewException((double)sizeof(CAtomGroup),__FILE__,__LINE__,__PRETTY_FUNCTION__);
 
5444
 
 
5445
                ag->CopyFrom((CAtomGroup*)p->m_oaVectors[z]);
 
5446
                m_oaVectors.Add(ag);
 
5447
        }
 
5448
 
 
5449
        m_faMinMaxDist.CopyFrom(&p->m_faMinMaxDist);
 
5450
 
 
5451
        if (p->m_pRDF != NULL)
 
5452
        {
 
5453
                try { m_pRDF = new CDF(); } catch(...) { m_pRDF = NULL; }
 
5454
                if (m_pRDF == NULL) NewException((double)sizeof(CDF),__FILE__,__LINE__,__PRETTY_FUNCTION__);
 
5455
                
 
5456
                m_pRDF->CopyFrom(p->m_pRDF);
 
5457
        }
 
5458
}
 
5459
 
 
5460
 
 
5461
void CADF::CopyFrom(CADF *p)
 
5462
{
 
5463
        int z, z2;
 
5464
        CAtomGroup *ag;
 
5465
 
 
5466
        m_bCosine = p->m_bCosine;
 
5467
        m_bFoldAngle = p->m_bFoldAngle;
 
5468
        m_bMirror = p->m_bMirror;
 
5469
        m_bOrtho[0] = p->m_bOrtho[0];
 
5470
        m_bOrtho[1] = p->m_bOrtho[1];
 
5471
        m_iVecType[0] = p->m_iVecType[0];
 
5472
        m_iVecType[1] = p->m_iVecType[1];
 
5473
        m_bSelf = p->m_bSelf;
 
5474
        m_bStat = p->m_bStat;
 
5475
        m_fMinAngle = p->m_fMinAngle;
 
5476
        m_fMaxAngle = p->m_fMaxAngle;
 
5477
        m_iCombinations = p->m_iCombinations;
 
5478
        m_iHistogramRes = p->m_iHistogramRes;
 
5479
        for (z=0;z<2;z++)
 
5480
                for (z2=0;z2<3;z2++)
 
5481
                        m_iRefOrSec[z][z2] = p->m_iRefOrSec[z][z2];
 
5482
        m_iResolution = p->m_iResolution;
 
5483
        m_iShowMol = p->m_iShowMol;
 
5484
 
 
5485
        if (p->m_sName != NULL)
 
5486
        {
 
5487
                try { m_sName = new char[strlen(p->m_sName)+1]; } catch(...) { m_sName = NULL; }
 
5488
                if (m_sName == NULL) NewException((double)(strlen(p->m_sName)+1)*sizeof(char),__FILE__,__LINE__,__PRETTY_FUNCTION__);
 
5489
                
 
5490
                strcpy(m_sName,p->m_sName);
 
5491
        } else m_sName = NULL;
 
5492
 
 
5493
        if (p->m_sShortName != NULL)
 
5494
        {
 
5495
                try { m_sShortName = new char[strlen(p->m_sShortName)+1]; } catch(...) { m_sShortName = NULL; }
 
5496
                if (m_sShortName == NULL) NewException((double)(strlen(p->m_sShortName)+1)*sizeof(char),__FILE__,__LINE__,__PRETTY_FUNCTION__);
 
5497
                
 
5498
                strcpy(m_sShortName,p->m_sShortName);
 
5499
        } else m_sShortName = NULL;
 
5500
 
 
5501
        if (p->m_baDataEnabled != NULL)
 
5502
        {
 
5503
                try { m_baDataEnabled = new CxByteArray[((CMolecule*)g_oaMolecules[m_iShowMol])->m_laSingleMolIndex.GetSize()]; } catch(...) { m_baDataEnabled = NULL; }
 
5504
                if (m_baDataEnabled == NULL) NewException((double)((CMolecule*)g_oaMolecules[m_iShowMol])->m_laSingleMolIndex.GetSize()*sizeof(CxByteArray),__FILE__,__LINE__,__PRETTY_FUNCTION__);
 
5505
                
 
5506
                for (z=0;z<((CMolecule*)g_oaMolecules[m_iShowMol])->m_laSingleMolIndex.GetSize();z++)
 
5507
                        m_baDataEnabled[z].CopyFrom(&p->m_baDataEnabled[z]);
 
5508
        }
 
5509
 
 
5510
        if (p->m_faData != NULL)
 
5511
        {
 
5512
                try { m_faData = new CxDoubleArray[((CMolecule*)g_oaMolecules[m_iShowMol])->m_laSingleMolIndex.GetSize()]; } catch(...) { m_faData = NULL; }
 
5513
                if (m_faData == NULL) NewException((double)((CMolecule*)g_oaMolecules[m_iShowMol])->m_laSingleMolIndex.GetSize()*sizeof(CxDoubleArray),__FILE__,__LINE__,__PRETTY_FUNCTION__);
 
5514
                
 
5515
                for (z=0;z<((CMolecule*)g_oaMolecules[m_iShowMol])->m_laSingleMolIndex.GetSize();z++)
 
5516
                        m_faData[z].CopyFrom(&p->m_faData[z]);
 
5517
        }
 
5518
 
 
5519
        for (z=0;z<p->m_oaVectors.GetSize();z++)
 
5520
        {
 
5521
                if (p->m_oaVectors[z] != NULL)
 
5522
                {
 
5523
                        try { ag = new CAtomGroup(); } catch(...) { ag = NULL; }
 
5524
                        if (ag == NULL) NewException((double)sizeof(CAtomGroup),__FILE__,__LINE__,__PRETTY_FUNCTION__);
 
5525
 
 
5526
                        ag->CopyFrom((CAtomGroup*)p->m_oaVectors[z]);
 
5527
                        m_oaVectors.Add(ag);
 
5528
                } else m_oaVectors.Add(NULL);
 
5529
        }
 
5530
 
 
5531
        m_faMinMaxAngle.CopyFrom(&p->m_faMinMaxAngle);
 
5532
 
 
5533
        if (p->m_pADF != NULL)
 
5534
        {
 
5535
                try { m_pADF = new CDF(); } catch(...) { m_pADF = NULL; }
 
5536
                if (m_pADF == NULL) NewException((double)sizeof(CDF),__FILE__,__LINE__,__PRETTY_FUNCTION__);
 
5537
                
 
5538
                m_pADF->CopyFrom(p->m_pADF);
 
5539
        }
 
5540
}
 
5541
 
 
5542
 
 
5543
void CConditionSubGroup::CopyFrom(CConditionSubGroup *p)
 
5544
{
 
5545
        int z;
 
5546
        CNbSearch *nb;
 
5547
 
 
5548
        m_fPassed = p->m_fPassed;
 
5549
        m_fTotal = p->m_fTotal;
 
5550
        m_iCombinations = p->m_iCombinations;
 
5551
        m_iNumber = p->m_iNumber;
 
5552
        m_iShowMol = p->m_iShowMol;
 
5553
        if (p->m_bTempPassed != NULL)
 
5554
        {
 
5555
                try { m_bTempPassed = new bool[g_iGesVirtAtomCount]; } catch(...) { m_bTempPassed = NULL; }
 
5556
                if (m_bTempPassed == NULL) NewException((double)g_iGesVirtAtomCount*sizeof(bool),__FILE__,__LINE__,__PRETTY_FUNCTION__);
 
5557
                
 
5558
                memcpy(m_bTempPassed,p->m_bTempPassed,sizeof(bool)*g_iGesVirtAtomCount);
 
5559
        }
 
5560
        for (z=0;z<p->m_oaConditions.GetSize();z++)
 
5561
        {
 
5562
                try { nb = new CNbSearch(); } catch(...) { nb = NULL; }
 
5563
                if (nb == NULL) NewException((double)sizeof(CNbSearch),__FILE__,__LINE__,__PRETTY_FUNCTION__);
 
5564
                
 
5565
                nb->CopyFrom((CNbSearch*)p->m_oaConditions[z]);
 
5566
                m_oaConditions.Add(nb);
 
5567
        }
 
5568
}
 
5569
 
 
5570
 
 
5571
void CConditionGroup::CopyFrom(CConditionGroup *p)
 
5572
{
 
5573
        int z;
 
5574
        CConditionSubGroup *sg;
 
5575
 
 
5576
        m_bInactive = p->m_bInactive;
 
5577
        m_iShowMol = p->m_iShowMol;
 
5578
        m_iRefMol = p->m_iRefMol;
 
5579
        m_iHistoGes = p->m_iHistoGes;
 
5580
        m_bAnyPassed = p->m_bAnyPassed;
 
5581
        m_fTableGes = p->m_fTableGes;
 
5582
        m_fPassed = p->m_fPassed;
 
5583
        m_fTotal = p->m_fTotal;
 
5584
        m_bInvertCondition = p->m_bInvertCondition;
 
5585
 
 
5586
        if (p->m_bAlwaysTrue != NULL)
 
5587
        {
 
5588
                try { m_bAlwaysTrue = new bool[((CMolecule*)g_oaMolecules[m_iShowMol])->m_laSingleMolIndex.GetSize()]; } catch(...) { m_bAlwaysTrue = NULL; }
 
5589
                if (m_bAlwaysTrue == NULL) NewException((double)((CMolecule*)g_oaMolecules[m_iShowMol])->m_laSingleMolIndex.GetSize()*sizeof(bool),__FILE__,__LINE__,__PRETTY_FUNCTION__);
 
5590
                
 
5591
                memcpy(m_bAlwaysTrue,p->m_bAlwaysTrue,sizeof(bool)*((CMolecule*)g_oaMolecules[m_iShowMol])->m_laSingleMolIndex.GetSize());
 
5592
        }
 
5593
        if (p->m_iPassCounter != NULL)
 
5594
        {
 
5595
                try { m_iPassCounter = new long[((CMolecule*)g_oaMolecules[m_iShowMol])->m_laSingleMolIndex.GetSize()]; } catch(...) { m_iPassCounter = NULL; }
 
5596
                if (m_iPassCounter == NULL) NewException((double)((CMolecule*)g_oaMolecules[m_iShowMol])->m_laSingleMolIndex.GetSize()*sizeof(long),__FILE__,__LINE__,__PRETTY_FUNCTION__);
 
5597
                
 
5598
                memcpy(m_iPassCounter,p->m_iPassCounter,sizeof(long)*((CMolecule*)g_oaMolecules[m_iShowMol])->m_laSingleMolIndex.GetSize());
 
5599
        }
 
5600
        if (p->m_iOMPassCounter != NULL)
 
5601
        {
 
5602
                try { m_iOMPassCounter = new long[((CMolecule*)g_oaMolecules[m_iShowMol])->m_laSingleMolIndex.GetSize()]; } catch(...) { m_iOMPassCounter = NULL; }
 
5603
                if (m_iOMPassCounter == NULL) NewException((double)((CMolecule*)g_oaMolecules[m_iShowMol])->m_laSingleMolIndex.GetSize()*sizeof(long),__FILE__,__LINE__,__PRETTY_FUNCTION__);
 
5604
                
 
5605
                memcpy(m_iOMPassCounter,p->m_iOMPassCounter,sizeof(long)*((CMolecule*)g_oaMolecules[m_iShowMol])->m_laSingleMolIndex.GetSize());
 
5606
        }
 
5607
        if (p->m_iRMPassCounter != NULL)
 
5608
        {
 
5609
                try { m_iRMPassCounter = new long[((CMolecule*)g_oaMolecules[m_iRefMol])->m_laSingleMolIndex.GetSize()]; } catch(...) { m_iRMPassCounter = NULL; }
 
5610
                if (m_iRMPassCounter == NULL) NewException((double)((CMolecule*)g_oaMolecules[m_iRefMol])->m_laSingleMolIndex.GetSize()*sizeof(long),__FILE__,__LINE__,__PRETTY_FUNCTION__);
 
5611
                
 
5612
                memcpy(m_iRMPassCounter,p->m_iRMPassCounter,sizeof(long)*((CMolecule*)g_oaMolecules[m_iRefMol])->m_laSingleMolIndex.GetSize());
 
5613
        }
 
5614
        for (z=0;z<p->m_oaConditionSubGroups.GetSize();z++)
 
5615
        {
 
5616
                try { sg = new CConditionSubGroup(); } catch(...) { sg = NULL; }
 
5617
                if (sg == NULL) NewException((double)sizeof(CConditionSubGroup),__FILE__,__LINE__,__PRETTY_FUNCTION__);
 
5618
                
 
5619
                sg->CopyFrom((CConditionSubGroup*)p->m_oaConditionSubGroups[z]);
 
5620
                m_oaConditionSubGroups.Add(sg);
 
5621
        }
 
5622
 
 
5623
        if (p->m_pTable != NULL)
 
5624
        {
 
5625
                try { m_pTable = new double[(((CConditionSubGroup*)m_oaConditionSubGroups[0])->m_iCombinations+1) * (((CConditionSubGroup*)m_oaConditionSubGroups[1])->m_iCombinations+1)]; } catch(...) { m_pTable = NULL; }
 
5626
                if (m_pTable == NULL) NewException((double)(((CConditionSubGroup*)m_oaConditionSubGroups[0])->m_iCombinations+1) * (((CConditionSubGroup*)m_oaConditionSubGroups[1])->m_iCombinations+1)*sizeof(double),__FILE__,__LINE__,__PRETTY_FUNCTION__);
 
5627
                
 
5628
                memcpy(m_pTable,p->m_pTable,sizeof(double)*(((CConditionSubGroup*)m_oaConditionSubGroups[0])->m_iCombinations+1) * (((CConditionSubGroup*)m_oaConditionSubGroups[1])->m_iCombinations+1));
 
5629
        }
 
5630
 
 
5631
        if (p->m_pHistogram != NULL)
 
5632
        {
 
5633
                try { m_pHistogram = new unsigned long[((CMolecule*)g_oaMolecules[m_iShowMol])->m_laSingleMolIndex.GetSize()+1]; } catch(...) { m_pHistogram = NULL; }
 
5634
                if (m_pHistogram == NULL) NewException((double)(((CMolecule*)g_oaMolecules[m_iShowMol])->m_laSingleMolIndex.GetSize()+1)*sizeof(unsigned long),__FILE__,__LINE__,__PRETTY_FUNCTION__);
 
5635
                
 
5636
                memcpy(m_pHistogram,p->m_pHistogram,sizeof(unsigned long)*(((CMolecule*)g_oaMolecules[m_iShowMol])->m_laSingleMolIndex.GetSize()+1));
 
5637
        }
 
5638
}
 
5639
 
 
5640
 
 
5641
void CConditionGroup::Parse_OnlyValues()
 
5642
{
 
5643
        BTIN;
 
5644
        int z;
 
5645
 
 
5646
        for (z=0;z<m_oaConditionSubGroups.GetSize();z++)
 
5647
        {
 
5648
                mprintf(YELLOW,">>> %d. set of conditions >>>\n\n",z+1);
 
5649
                ((CConditionSubGroup*)m_oaConditionSubGroups[z])->Parse_OnlyValues();
 
5650
                mprintf(YELLOW,"<<< End of %d. set of conditions <<<\n\n",z+1);
 
5651
        }
 
5652
}
 
5653
 
 
5654
 
 
5655
void CConditionSubGroup::Parse_OnlyValues()
 
5656
{
 
5657
        BTIN;
 
5658
        int z;
 
5659
 
 
5660
        for (z=0;z<m_oaConditions.GetSize();z++)
 
5661
        {
 
5662
                mprintf(YELLOW,"    >>> %d. condition within this set >>>\n\n",z+1);
 
5663
                ((CNbSearch*)m_oaConditions[z])->Parse_OnlyValues();
 
5664
                mprintf(YELLOW,"\n    <<< End of %d. condition <<<\n\n",z+1);
 
5665
        }
 
5666
        BTOUT;
 
5667
}
 
5668
 
 
5669
 
 
5670
void CConditionGroup::CopyResults(CConditionGroup *p)
 
5671
{
 
5672
        int z;
 
5673
 
 
5674
        for (z=0;z<m_oaConditionSubGroups.GetSize();z++)
 
5675
                ((CConditionSubGroup*)m_oaConditionSubGroups[z])->CopyResults((CConditionSubGroup*)p->m_oaConditionSubGroups[z]);
 
5676
}
 
5677
 
 
5678
 
 
5679
void CConditionSubGroup::CopyResults(CConditionSubGroup *p)
 
5680
{
 
5681
        int z;
 
5682
 
 
5683
        for (z=0;z<m_oaConditions.GetSize();z++)
 
5684
                ((CNbSearch*)m_oaConditions[z])->CopyResults((CNbSearch*)p->m_oaConditions[z]);
 
5685
}
 
5686
 
 
5687
 
 
5688
void CConditionGroup::ReScan(CSingleMolecule *rm)
 
5689
{
 
5690
        BXIN;
 
5691
        int z, z2, t1, t2, i;
 
5692
 
 
5693
        if (m_bInactive)
 
5694
                return;
 
5695
 
 
5696
        for (z=0;z<m_oaConditionSubGroups.GetSize();z++)
 
5697
                ((CConditionSubGroup*)m_oaConditionSubGroups[z])->ReScan(rm);
 
5698
 
 
5699
        if (m_oaConditionSubGroups.GetSize() == 2)
 
5700
        {
 
5701
                for (z=0;z<((CMolecule*)g_oaMolecules[m_iShowMol])->m_laSingleMolIndex.GetSize();z++)
 
5702
                {
 
5703
                        t1 = 0;
 
5704
                        t2 = 0;
 
5705
                        for (z2=0;z2<((CConditionSubGroup*)m_oaConditionSubGroups[0])->m_oaConditions.GetSize();z2++)
 
5706
                                t1 += ((CNbSearch*)((CConditionSubGroup*)m_oaConditionSubGroups[0])->m_oaConditions[z2])->m_iCombPassCount[z];
 
5707
                        for (z2=0;z2<((CConditionSubGroup*)m_oaConditionSubGroups[1])->m_oaConditions.GetSize();z2++)
 
5708
                                t2 += ((CNbSearch*)((CConditionSubGroup*)m_oaConditionSubGroups[1])->m_oaConditions[z2])->m_iCombPassCount[z];
 
5709
                        m_pTable[t1*(((CConditionSubGroup*)m_oaConditionSubGroups[1])->m_iCombinations+1)+t2]++;
 
5710
                        m_fTableGes++;
 
5711
                }
 
5712
        }
 
5713
 
 
5714
        i = 0;
 
5715
        for (z=0;z<((CMolecule*)g_oaMolecules[m_iShowMol])->m_laSingleMolIndex.GetSize();z++)
 
5716
        {
 
5717
                m_fTotal++;
 
5718
                if (m_bInvertCondition)
 
5719
                {
 
5720
                        for (z2=0;z2<m_oaConditionSubGroups.GetSize();z2++)
 
5721
                                if (((CConditionSubGroup*)m_oaConditionSubGroups[z2])->Contains(z))
 
5722
                                        goto _nopass;
 
5723
                        m_fPassed++;
 
5724
                        m_iPassCounter[z]++;
 
5725
                        m_bAnyPassed = true;
 
5726
                } else
 
5727
                {
 
5728
                        for (z2=0;z2<m_oaConditionSubGroups.GetSize();z2++)
 
5729
                                if (((CConditionSubGroup*)m_oaConditionSubGroups[z2])->Contains(z))
 
5730
                                {
 
5731
//                                      mprintf("passed[%d]++\n",z);
 
5732
                                        m_fPassed++;
 
5733
                                        m_iPassCounter[z]++;
 
5734
                                        m_bAnyPassed = true;
 
5735
                                        i++;
 
5736
                                        goto _nopass;
 
5737
                                }
 
5738
                }
 
5739
_nopass:;
 
5740
        }
 
5741
        m_pHistogram[i]++;
 
5742
        m_iHistoGes++;
 
5743
 
 
5744
        BXOUT;
 
5745
}
 
5746
 
 
5747
 
 
5748
void CConditionSubGroup::ReScan(CSingleMolecule *rm)
 
5749
{
 
5750
        int z, z2;
 
5751
 
 
5752
        for (z=0;z<m_oaConditions.GetSize();z++)
 
5753
                ((CNbSearch*)m_oaConditions[z])->ReScan(rm);
 
5754
 
 
5755
        for (z=0;z<((CMolecule*)g_oaMolecules[m_iShowMol])->m_laSingleMolIndex.GetSize();z++)
 
5756
        {
 
5757
                m_fTotal++;
 
5758
                for (z2=0;z2<m_oaConditions.GetSize();z2++)
 
5759
                        if (!((CNbSearch*)m_oaConditions[z2])->m_bPassed[z])
 
5760
                                goto _nopass;
 
5761
                m_fPassed++;
 
5762
_nopass:;
 
5763
        }
 
5764
}
 
5765
 
 
5766
 
 
5767
CNbSearch* CConditionGroup::AddSingleCondition(int rm, int sm, int gridmode)
 
5768
{
 
5769
        BTIN;
 
5770
        CConditionSubGroup *sg;
 
5771
        int z;
 
5772
 
 
5773
        m_iShowMol = sm;
 
5774
        m_iRefMol = rm;
 
5775
 
 
5776
        try { m_bAlwaysTrue = new bool[((CMolecule*)g_oaMolecules[sm])->m_laSingleMolIndex.GetSize()]; } catch(...) { m_bAlwaysTrue = NULL; }
 
5777
        if (m_bAlwaysTrue == NULL) NewException((double)((CMolecule*)g_oaMolecules[sm])->m_laSingleMolIndex.GetSize()*sizeof(bool),__FILE__,__LINE__,__PRETTY_FUNCTION__);
 
5778
        
 
5779
        try { m_iPassCounter = new long[((CMolecule*)g_oaMolecules[sm])->m_laSingleMolIndex.GetSize()]; } catch(...) { m_iPassCounter = NULL; }
 
5780
        if (m_iPassCounter == NULL) NewException((double)((CMolecule*)g_oaMolecules[sm])->m_laSingleMolIndex.GetSize()*sizeof(long),__FILE__,__LINE__,__PRETTY_FUNCTION__);
 
5781
        
 
5782
        try { m_iOMPassCounter = new long[((CMolecule*)g_oaMolecules[sm])->m_laSingleMolIndex.GetSize()]; } catch(...) { m_iOMPassCounter = NULL; }
 
5783
        if (m_iOMPassCounter == NULL) NewException((double)((CMolecule*)g_oaMolecules[sm])->m_laSingleMolIndex.GetSize()*sizeof(long),__FILE__,__LINE__,__PRETTY_FUNCTION__);
 
5784
        
 
5785
        for (z=0;z<((CMolecule*)g_oaMolecules[sm])->m_laSingleMolIndex.GetSize();z++)
 
5786
        {
 
5787
                m_bAlwaysTrue[z] = false;
 
5788
                m_iPassCounter[z] = 0;
 
5789
                m_iOMPassCounter[z] = 0;
 
5790
        }
 
5791
 
 
5792
        try { m_iRMPassCounter = new long[((CMolecule*)g_oaMolecules[rm])->m_laSingleMolIndex.GetSize()]; } catch(...) { m_iRMPassCounter = NULL; }
 
5793
        if (m_iRMPassCounter == NULL) NewException((double)((CMolecule*)g_oaMolecules[rm])->m_laSingleMolIndex.GetSize()*sizeof(long),__FILE__,__LINE__,__PRETTY_FUNCTION__);
 
5794
        
 
5795
        for (z=0;z<((CMolecule*)g_oaMolecules[rm])->m_laSingleMolIndex.GetSize();z++)
 
5796
                m_iRMPassCounter[z] = 0;
 
5797
 
 
5798
        try { sg = new CConditionSubGroup(); } catch(...) { sg = NULL; }
 
5799
        if (sg == NULL) NewException((double)sizeof(CConditionSubGroup),__FILE__,__LINE__,__PRETTY_FUNCTION__);
 
5800
        
 
5801
        sg->m_iShowMol = m_iShowMol;
 
5802
        sg->m_iNumber = m_oaConditionSubGroups.GetSize();
 
5803
        m_oaConditionSubGroups.Add(sg);
 
5804
        
 
5805
        m_bInvertCondition = false;
 
5806
 
 
5807
        m_iHistoGes = 0;
 
5808
 
 
5809
        try { m_pHistogram = new unsigned long[((CMolecule*)g_oaMolecules[sm])->m_laSingleMolIndex.GetSize()+1]; } catch(...) { m_pHistogram = NULL; }
 
5810
        if (m_pHistogram == NULL) NewException((double)(((CMolecule*)g_oaMolecules[sm])->m_laSingleMolIndex.GetSize()+1)*sizeof(unsigned long),__FILE__,__LINE__,__PRETTY_FUNCTION__);
 
5811
        
 
5812
        for (z=0;z<((CMolecule*)g_oaMolecules[sm])->m_laSingleMolIndex.GetSize()+1;z++)
 
5813
                m_pHistogram[z] = 0;
 
5814
 
 
5815
        BTOUT;
 
5816
        return sg->AddSingleCondition(rm,sm,gridmode);
 
5817
}
 
5818
 
 
5819
 
 
5820
CNbSearch* CConditionSubGroup::AddSingleCondition(int rm, int sm, int gridmode)
 
5821
{
 
5822
        BTIN;
 
5823
        CNbSearch *n;
 
5824
 
 
5825
        m_iCombinations = 0;
 
5826
 
 
5827
        try { n = new CNbSearch(); } catch(...) { n = NULL; }
 
5828
        if (n == NULL) NewException((double)sizeof(CNbSearch),__FILE__,__LINE__,__PRETTY_FUNCTION__);
 
5829
        
 
5830
        n->m_iNumber = m_oaConditions.GetSize();
 
5831
        m_oaConditions.Add(n);
 
5832
        n->ParseGrid(rm,sm,gridmode);
 
5833
        m_iCombinations += n->m_iCombinationsEnabled;
 
5834
 
 
5835
        try { m_bTempPassed = new bool[g_iGesVirtAtomCount]; } catch(...) { m_bTempPassed = NULL; }
 
5836
        if (m_bTempPassed == NULL) NewException((double)g_iGesVirtAtomCount*sizeof(bool),__FILE__,__LINE__,__PRETTY_FUNCTION__);
 
5837
 
 
5838
        BTOUT;
 
5839
        return n;
 
5840
}
 
5841
 
 
5842
 
 
5843
void CObservation::BuildTimeDiff(CDF *df, bool ddf)
 
5844
{
 
5845
        int z, z2, z3, z4, i;
 
5846
        CxFloatArray *ptfa;
 
5847
        double tf, tfa, tfsq, tfs, tf0;
 
5848
        char buf[256];
 
5849
 
 
5850
        try { df->m_pTimeDiff = new CDF(); } catch(...) { df->m_pTimeDiff = NULL; }
 
5851
        if (df->m_pTimeDiff == NULL) NewException((double)sizeof(CDF),__FILE__,__LINE__,__PRETTY_FUNCTION__);
 
5852
        
 
5853
        df->m_pTimeDiff->m_iResolution = m_iTimeDiffDepth;
 
5854
        df->m_pTimeDiff->m_fMinVal = 0;
 
5855
        df->m_pTimeDiff->m_fMaxVal = m_iTimeDiffDepth * g_fTimestepLength / 1000.0;
 
5856
        df->m_pTimeDiff->Create();
 
5857
        df->m_pTimeDiff->SetLabelX("Tau [ps]");
 
5858
        sprintf(buf,"Delta ");
 
5859
        strcat(buf,df->m_sLabelX);
 
5860
        df->m_pTimeDiff->SetLabelY(buf);
 
5861
 
 
5862
        try { df->m_pTimeDiffAbs = new CDF(); } catch(...) { df->m_pTimeDiffAbs = NULL; }
 
5863
        if (df->m_pTimeDiffAbs == NULL) NewException((double)sizeof(CDF),__FILE__,__LINE__,__PRETTY_FUNCTION__);
 
5864
        
 
5865
        df->m_pTimeDiffAbs->m_iResolution = m_iTimeDiffDepth;
 
5866
        df->m_pTimeDiffAbs->m_fMinVal = 0;
 
5867
        df->m_pTimeDiffAbs->m_fMaxVal = m_iTimeDiffDepth * g_fTimestepLength / 1000.0;
 
5868
        df->m_pTimeDiffAbs->Create();
 
5869
        df->m_pTimeDiffAbs->SetLabelX("Tau [ps]");
 
5870
        df->m_pTimeDiffAbs->SetLabelY(buf);
 
5871
 
 
5872
        sprintf(buf,"Delta Square ");
 
5873
        strcat(buf,df->m_sLabelX);
 
5874
 
 
5875
        try { df->m_pTimeDiffSqr = new CDF(); } catch(...) { df->m_pTimeDiffSqr = NULL; }
 
5876
        if (df->m_pTimeDiffSqr == NULL) NewException((double)sizeof(CDF),__FILE__,__LINE__,__PRETTY_FUNCTION__);
 
5877
        
 
5878
        df->m_pTimeDiffSqr->m_iResolution = m_iTimeDiffDepth;
 
5879
        df->m_pTimeDiffSqr->m_fMinVal = 0;
 
5880
        df->m_pTimeDiffSqr->m_fMaxVal = m_iTimeDiffDepth * g_fTimestepLength / 1000.0;
 
5881
        df->m_pTimeDiffSqr->Create();
 
5882
        df->m_pTimeDiffSqr->SetLabelX("Tau [ps]");
 
5883
        df->m_pTimeDiffSqr->SetLabelY(buf);
 
5884
 
 
5885
        if (m_b3DTimeDiff)
 
5886
        {
 
5887
                sprintf(buf,"Delta ");
 
5888
                strcat(buf,df->m_sLabelX);
 
5889
 
 
5890
                try { df->m_p3DTimeDiff = new C2DF(); } catch(...) { df->m_p3DTimeDiff = NULL; }
 
5891
                if (df->m_p3DTimeDiff == NULL) NewException((double)sizeof(C2DF),__FILE__,__LINE__,__PRETTY_FUNCTION__);
 
5892
                
 
5893
                df->m_p3DTimeDiff->m_iRes[0] = m_iTimeDiffDepth/m_iTimeDiffStride3D;
 
5894
                df->m_p3DTimeDiff->m_iRes[1] = m_iTimeDiffRes3D;
 
5895
                df->m_p3DTimeDiff->m_fMinVal[0] = 0;
 
5896
                df->m_p3DTimeDiff->m_fMaxVal[0] = m_iTimeDiffDepth * g_fTimestepLength / 1000.0;
 
5897
                df->m_p3DTimeDiff->m_fMinVal[1] = m_fTimeDiffMinVal3D;
 
5898
                df->m_p3DTimeDiff->m_fMaxVal[1] = m_fTimeDiffMaxVal3D;
 
5899
                df->m_p3DTimeDiff->Create();
 
5900
                df->m_p3DTimeDiff->SetLabelX("Tau [ps]");
 
5901
                df->m_p3DTimeDiff->SetLabelY(df->m_sLabelX);
 
5902
                df->m_p3DTimeDiff->SetLabelZ(buf);
 
5903
 
 
5904
                try { df->m_p3DTimeDiffAbs = new C2DF(); } catch(...) { df->m_p3DTimeDiffAbs = NULL; }
 
5905
                if (df->m_p3DTimeDiffAbs == NULL) NewException((double)sizeof(C2DF),__FILE__,__LINE__,__PRETTY_FUNCTION__);
 
5906
                
 
5907
                df->m_p3DTimeDiffAbs->m_iRes[0] = m_iTimeDiffDepth/m_iTimeDiffStride3D;
 
5908
                df->m_p3DTimeDiffAbs->m_iRes[1] = m_iTimeDiffRes3D;
 
5909
                df->m_p3DTimeDiffAbs->m_fMinVal[0] = 0;
 
5910
                df->m_p3DTimeDiffAbs->m_fMaxVal[0] = m_iTimeDiffDepth * g_fTimestepLength / 1000.0;
 
5911
                df->m_p3DTimeDiffAbs->m_fMinVal[1] = m_fTimeDiffMinVal3D;
 
5912
                df->m_p3DTimeDiffAbs->m_fMaxVal[1] = m_fTimeDiffMaxVal3D;
 
5913
                df->m_p3DTimeDiffAbs->Create();
 
5914
                df->m_p3DTimeDiffAbs->SetLabelX("Tau [ps]");
 
5915
                df->m_p3DTimeDiffAbs->SetLabelY(df->m_sLabelX);
 
5916
                df->m_p3DTimeDiffAbs->SetLabelZ(buf);
 
5917
 
 
5918
                if (m_iTimeDiffDistSteps != 0)
 
5919
                {
 
5920
                        try { df->m_pTimeDiffDistPairs = new C2DF*[m_iTimeDiffDepth/m_iTimeDiffStride3D/m_iTimeDiffDistSteps]; } catch(...) { df->m_pTimeDiffDistPairs = NULL; }
 
5921
                        if (df->m_pTimeDiffDistPairs == NULL) NewException((double)m_iTimeDiffDepth/m_iTimeDiffStride3D/m_iTimeDiffDistSteps*sizeof(C2DF*),__FILE__,__LINE__,__PRETTY_FUNCTION__);
 
5922
                        
 
5923
                        for (z=0;z<m_iTimeDiffDepth/m_iTimeDiffStride3D/m_iTimeDiffDistSteps;z++)
 
5924
                        {
 
5925
                                try { df->m_pTimeDiffDistPairs[z] = new C2DF(); } catch(...) { df->m_pTimeDiffDistPairs[z] = NULL; }
 
5926
                                if (df->m_pTimeDiffDistPairs[z] == NULL) NewException((double)sizeof(C2DF),__FILE__,__LINE__,__PRETTY_FUNCTION__);
 
5927
                                
 
5928
                                df->m_pTimeDiffDistPairs[z]->m_iRes[0] = m_iTimeDiffDistResX;
 
5929
                                df->m_pTimeDiffDistPairs[z]->m_iRes[1] = m_iTimeDiffDistResY;
 
5930
                                df->m_pTimeDiffDistPairs[z]->m_fMinVal[0] = m_fTimeDiffDistMinValX;
 
5931
                                df->m_pTimeDiffDistPairs[z]->m_fMaxVal[0] = m_fTimeDiffDistMaxValX;
 
5932
                                df->m_pTimeDiffDistPairs[z]->m_fMinVal[1] = m_fTimeDiffDistMinValY;
 
5933
                                df->m_pTimeDiffDistPairs[z]->m_fMaxVal[1] = m_fTimeDiffDistMaxValY;
 
5934
                                df->m_pTimeDiffDistPairs[z]->Create();
 
5935
                                df->m_pTimeDiffDistPairs[z]->SetLabelX(df->m_sLabelX);
 
5936
                                df->m_pTimeDiffDistPairs[z]->SetLabelY(df->m_sLabelX);
 
5937
                        }
 
5938
                }
 
5939
 
 
5940
                try { df->m_pTimeDiffDist3DF = new C3DF(); } catch(...) { df->m_pTimeDiffDist3DF = NULL; }
 
5941
                if (df->m_pTimeDiffDist3DF == NULL) NewException((double)sizeof(C3DF),__FILE__,__LINE__,__PRETTY_FUNCTION__);
 
5942
                
 
5943
                df->m_pTimeDiffDist3DF->m_iRes[0] = m_iTimeDiffDistResX;
 
5944
                df->m_pTimeDiffDist3DF->m_iRes[1] = m_iTimeDiffDistResY;
 
5945
                df->m_pTimeDiffDist3DF->m_iRes[2] = m_iTimeDiffDepth/m_iTimeDiffStride3D;
 
5946
                df->m_pTimeDiffDist3DF->m_fMinVal[0] = m_fTimeDiffDistMinValX;
 
5947
                df->m_pTimeDiffDist3DF->m_fMaxVal[0] = m_fTimeDiffDistMaxValX;
 
5948
                df->m_pTimeDiffDist3DF->m_fMinVal[1] = m_fTimeDiffDistMinValY;
 
5949
                df->m_pTimeDiffDist3DF->m_fMaxVal[1] = m_fTimeDiffDistMaxValY;
 
5950
                df->m_pTimeDiffDist3DF->m_fMinVal[2] = 0;
 
5951
                df->m_pTimeDiffDist3DF->m_fMaxVal[2] = m_iTimeDiffDepth * g_fTimestepLength / 1000.0;
 
5952
                df->m_pTimeDiffDist3DF->Create();
 
5953
                df->m_pTimeDiffDist3DF->SetLabelX(df->m_sLabelX);
 
5954
                df->m_pTimeDiffDist3DF->SetLabelY(df->m_sLabelX);
 
5955
 
 
5956
                sprintf(buf,"Delta Square ");
 
5957
                strcat(buf,df->m_sLabelX);
 
5958
 
 
5959
                try { df->m_p3DTimeDiffSqr = new C2DF(); } catch(...) { df->m_p3DTimeDiffSqr = NULL; }
 
5960
                if (df->m_p3DTimeDiffSqr == NULL) NewException((double)sizeof(C3DF),__FILE__,__LINE__,__PRETTY_FUNCTION__);
 
5961
                
 
5962
                df->m_p3DTimeDiffSqr->m_iRes[0] = m_iTimeDiffDepth/m_iTimeDiffStride3D;
 
5963
                df->m_p3DTimeDiffSqr->m_iRes[1] = m_iTimeDiffRes3D;
 
5964
                df->m_p3DTimeDiffSqr->m_fMinVal[0] = 0;
 
5965
                df->m_p3DTimeDiffSqr->m_fMaxVal[0] = m_iTimeDiffDepth * g_fTimestepLength / 1000.0;
 
5966
                df->m_p3DTimeDiffSqr->m_fMinVal[1] = m_fTimeDiffMinVal3D;
 
5967
                df->m_p3DTimeDiffSqr->m_fMaxVal[1] = m_fTimeDiffMaxVal3D;
 
5968
                df->m_p3DTimeDiffSqr->Create();
 
5969
                df->m_p3DTimeDiffSqr->SetLabelX("Tau [ps]");
 
5970
                df->m_p3DTimeDiffSqr->SetLabelY(df->m_sLabelX);
 
5971
                df->m_p3DTimeDiffSqr->SetLabelZ(buf);
 
5972
 
 
5973
                try { df->m_p3DTimeDiffT = new C2DF(); } catch(...) { df->m_p3DTimeDiffT = NULL; }
 
5974
                if (df->m_p3DTimeDiffT == NULL) NewException((double)sizeof(C2DF),__FILE__,__LINE__,__PRETTY_FUNCTION__);
 
5975
                
 
5976
                df->m_p3DTimeDiffT->m_iRes[0] = m_iTimeDiffDepth/m_iTimeDiffStride3D;
 
5977
                df->m_p3DTimeDiffT->m_iRes[1] = m_iTimeDiffRes3D;
 
5978
                df->m_p3DTimeDiffT->m_fMinVal[0] = 0;
 
5979
                df->m_p3DTimeDiffT->m_fMaxVal[0] = m_iTimeDiffDepth * g_fTimestepLength / 1000.0;
 
5980
                df->m_p3DTimeDiffT->m_fMinVal[1] = m_fTimeDiffMinVal3D;
 
5981
                df->m_p3DTimeDiffT->m_fMaxVal[1] = m_fTimeDiffMaxVal3D;
 
5982
                df->m_p3DTimeDiffT->Create();
 
5983
        }
 
5984
 
 
5985
        for (z2=0;z2<df->m_oaTimeDiffBuf.GetSize();z2++)
 
5986
        {
 
5987
                mprintf("      %4d/%d 2D  [",z2+1,df->m_oaTimeDiffBuf.GetSize());
 
5988
                ptfa = (CxFloatArray*)df->m_oaTimeDiffBuf[z2];
 
5989
                tfs = m_iTimeDiffDepth/50.0;
 
5990
                for (z3=0;z3<m_iTimeDiffDepth;z3++) // Das ist das Tau
 
5991
                {
 
5992
                        if (fmod(z3,tfs) < 1.0)
 
5993
                                mprintf(WHITE,"#");
 
5994
                        tf = 0;
 
5995
                        tfa = 0;
 
5996
                        tfsq = 0;
 
5997
                        for (z4=0;z4<(int)ptfa->GetSize()-z3-1;z4++) // Das ist der Startpunkt
 
5998
                        {
 
5999
                                tf0 = (*ptfa)[z3+z4]-(*ptfa)[z4];
 
6000
                                if (ddf)
 
6001
                                {
 
6002
                                        if (tf0 > 180.0)
 
6003
                                                tf0 -= 360.0;
 
6004
                                        if (tf0 <= -180.0)
 
6005
                                                tf0 += 360.0;
 
6006
                                }
 
6007
                                tfa += fabs(tf0);
 
6008
                                tf += tf0;
 
6009
                                tfsq += tf0 * tf0;
 
6010
                        }
 
6011
                        df->m_pTimeDiff->AddToBin_Int(z3,tf/(ptfa->GetSize()-z3-1));
 
6012
                        df->m_pTimeDiffAbs->AddToBin_Int(z3,tfa/(ptfa->GetSize()-z3-1));
 
6013
                        df->m_pTimeDiffSqr->AddToBin_Int(z3,tfsq/(ptfa->GetSize()-z3-1));
 
6014
 
 
6015
                        df->m_pTimeDiff->m_fBinEntries += ptfa->GetSize()-z3-2;
 
6016
                        df->m_pTimeDiffAbs->m_fBinEntries += ptfa->GetSize()-z3-2;
 
6017
                        df->m_pTimeDiffSqr->m_fBinEntries += ptfa->GetSize()-z3-2;
 
6018
                }
 
6019
                mprintf("]\n");
 
6020
                if (m_b3DTimeDiff)
 
6021
                {
 
6022
                        mprintf("      %4d/%d 3D  [",z2+1,df->m_oaTimeDiffBuf.GetSize());
 
6023
                        tfs = m_iTimeDiffDepth/50.0;
 
6024
                        for (z3=0;z3<m_iTimeDiffDepth;z3+=m_iTimeDiffStride3D) // Das ist das Tau
 
6025
                        {
 
6026
                                if (fmod(z3,tfs) < 1.0)
 
6027
                                        mprintf(WHITE,"#");
 
6028
                                i = z3/m_iTimeDiffStride3D;
 
6029
                                for (z4=0;z4<(int)ptfa->GetSize()-z3-1;z4++) // Das ist der Startpunkt
 
6030
                                {
 
6031
                                        tf0 = (*ptfa)[z3+z4]-(*ptfa)[z4];
 
6032
                                        if (ddf)
 
6033
                                        {
 
6034
                                                if (tf0 > 180.0)
 
6035
                                                        tf0 -= 360.0;
 
6036
                                                if (tf0 <= -180.0)
 
6037
                                                        tf0 += 360.0;
 
6038
                                        }
 
6039
                                        df->m_p3DTimeDiff->AddToBin_IntX(i,(*ptfa)[z4],tf0);
 
6040
                                        df->m_p3DTimeDiffAbs->AddToBin_IntX(i,(*ptfa)[z4],fabs(tf0));
 
6041
                                        df->m_p3DTimeDiffSqr->AddToBin_IntX(i,(*ptfa)[z4],tf0*tf0);
 
6042
                                        df->m_p3DTimeDiffT->AddToBin_IntX(i,(*ptfa)[z4],1.0);
 
6043
                                        df->m_pTimeDiffDist3DF->AddToBin_IntZ((*ptfa)[z4],(*ptfa)[z3+z4],i);
 
6044
                                        if (m_iTimeDiffDistSteps != 0)
 
6045
                                                if ((i % m_iTimeDiffDistSteps) == 0)
 
6046
                                                        df->m_pTimeDiffDistPairs[i/m_iTimeDiffDistSteps]->AddToBin((*ptfa)[z4],(*ptfa)[z3+z4]);
 
6047
                                }
 
6048
                        }
 
6049
                        mprintf("]\n");
 
6050
                }
 
6051
        }
 
6052
        for (z3=0;z3<m_iTimeDiffDepth;z3++) // Das ist das Tau
 
6053
        {
 
6054
                df->m_pTimeDiff->m_pBin[z3] /= df->m_oaTimeDiffBuf.GetSize();
 
6055
                df->m_pTimeDiffAbs->m_pBin[z3] /= df->m_oaTimeDiffBuf.GetSize();
 
6056
                df->m_pTimeDiffSqr->m_pBin[z3] /= df->m_oaTimeDiffBuf.GetSize();
 
6057
        }
 
6058
        if (m_b3DTimeDiff)
 
6059
        {
 
6060
                for (z2=0;z2<df->m_p3DTimeDiff->m_iRes[0]*df->m_p3DTimeDiff->m_iRes[1];z2++)
 
6061
                {
 
6062
                        if (df->m_p3DTimeDiffT->m_pBin[z2] != 0)
 
6063
                        {
 
6064
                                df->m_p3DTimeDiff->m_pBin[z2] /= df->m_p3DTimeDiffT->m_pBin[z2];
 
6065
                                df->m_p3DTimeDiffAbs->m_pBin[z2] /= df->m_p3DTimeDiffT->m_pBin[z2];
 
6066
                                df->m_p3DTimeDiffSqr->m_pBin[z2] /= df->m_p3DTimeDiffT->m_pBin[z2];
 
6067
                        }
 
6068
                }
 
6069
                if (m_iTimeDiffDistSteps != 0)
 
6070
                        for (z=0;z<m_iTimeDiffDepth/m_iTimeDiffStride3D/m_iTimeDiffDistSteps;z++)
 
6071
                                df->m_pTimeDiffDistPairs[z]->NormalizeBinIntegral(1000000.0);
 
6072
        }
 
6073
}
 
6074
 
 
6075
 
 
6076
void CObservation::WriteTimeDiff(CDF *df, const char *anaup, const char *analow, const char *name, const char *multibuf, bool ddf)
 
6077
{
 
6078
        char buf[256];
 
6079
        int z, z2;
 
6080
        C3DF *temp3DF;
 
6081
 
 
6082
        mprintf("    Creating temporal difference plot...\n");
 
6083
        BuildTimeDiff(df,ddf);
 
6084
        mprintf("      (%.0f bin entries)\n",df->m_pTimeDiff->m_fBinEntries);
 
6085
        sprintf(buf,"%s_timediff_%s%s.csv",analow,name,multibuf);
 
6086
        mprintf("      Saving %s temporal difference plot as \"%s\"...\n",anaup,buf);
 
6087
        df->m_pTimeDiff->Write("",buf,"",true);
 
6088
        sprintf(buf,"%s_timediff_%s%s.agr",analow,name,multibuf);
 
6089
        mprintf("      Saving %s temporal difference plot AGR file as \"%s\"...\n",anaup,buf);
 
6090
        df->m_pTimeDiff->WriteAgr("",buf,"",name,false);
 
6091
 
 
6092
        sprintf(buf,"%s_timediff_%s%s_abs.csv",analow,name,multibuf);
 
6093
        mprintf("      Saving %s absolute temporal difference plot as \"%s\"...\n",anaup,buf);
 
6094
        df->m_pTimeDiffAbs->Write("",buf,"",true);
 
6095
        sprintf(buf,"%s_timediff_%s%s_abs.agr",analow,name,multibuf);
 
6096
        mprintf("      Saving %s absolute temporal difference plot AGR file as \"%s\"...\n",anaup,buf);
 
6097
        df->m_pTimeDiffAbs->WriteAgr("",buf,"",name,false);
 
6098
 
 
6099
        sprintf(buf,"%s_timediff_%s%s_sqr.csv",analow,name,multibuf);
 
6100
        mprintf("      Saving %s squared temporal difference plot as \"%s\"...\n",anaup,buf);
 
6101
        df->m_pTimeDiffSqr->Write("",buf,"",true);
 
6102
        sprintf(buf,"%s_timediff_%s%s_sqr.agr",analow,name,multibuf);
 
6103
        mprintf("      Saving %s squared temporal difference plot AGR file as \"%s\"...\n",anaup,buf);
 
6104
        df->m_pTimeDiffSqr->WriteAgr("",buf,"",name,false);
 
6105
 
 
6106
        if (m_b3DTimeDiff)
 
6107
        {
 
6108
                mprintf("    Writing temporal 3D difference plot...\n");
 
6109
                mprintf("      (%.0f bin entries)\n",df->m_p3DTimeDiff->m_fBinEntries);
 
6110
                sprintf(buf,"%s_timediff_%s%s_triples.csv",analow,name,multibuf);
 
6111
                mprintf("      Saving %s temporal difference plot triples as \"%s\"...\n",anaup,buf);
 
6112
                df->m_p3DTimeDiff->Write("",buf,"");
 
6113
                sprintf(buf,"%s_timediff_%s%s_matrix.csv",analow,name,multibuf);
 
6114
                mprintf("      Saving %s temporal difference plot matrix as \"%s\"...\n",anaup,buf);
 
6115
                df->m_p3DTimeDiff->WriteCSV("",buf,"");
 
6116
                sprintf(buf,"%s_timediff_%s%s.nb",analow,name,multibuf);
 
6117
                mprintf("      Saving %s temporal difference plot Mathematica Notebook as \"%s\"...\n",anaup,buf);
 
6118
                df->m_p3DTimeDiff->WriteMathematicaNb("",buf,"",false);
 
6119
                sprintf(buf,"%s_timediff_%s%s",analow,name,multibuf);
 
6120
                mprintf("      Saving %s temporal difference plot Gnuplot Input as \"%s.gp\"...\n",anaup,buf);
 
6121
                df->m_p3DTimeDiff->WriteGnuplotInput("",buf,"",false);
 
6122
 
 
6123
                sprintf(buf,"%s_timediff_%s%s_triples_abs.csv",analow,name,multibuf);
 
6124
                mprintf("      Saving %s absolute temporal difference plot triples as \"%s\"...\n",anaup,buf);
 
6125
                df->m_p3DTimeDiffAbs->Write("",buf,"");
 
6126
                sprintf(buf,"%s_timediff_%s%s_matrix_abs.csv",analow,name,multibuf);
 
6127
                mprintf("      Saving %s absolute temporal difference plot matrix as \"%s\"...\n",anaup,buf);
 
6128
                df->m_p3DTimeDiffAbs->WriteCSV("",buf,"");
 
6129
                sprintf(buf,"%s_timediff_%s%s_abs.nb",analow,name,multibuf);
 
6130
                mprintf("      Saving %s absolute temporal difference plot Mathematica Notebook as \"%s\"...\n",anaup,buf);
 
6131
                df->m_p3DTimeDiffAbs->WriteMathematicaNb("",buf,"",false);
 
6132
                sprintf(buf,"%s_timediff_%s%s_abs",analow,name,multibuf);
 
6133
                mprintf("      Saving %s absolute temporal difference plot Gnuplot Input as \"%s.gp\"...\n",anaup,buf);
 
6134
                df->m_p3DTimeDiffAbs->WriteGnuplotInput("",buf,"",false);
 
6135
 
 
6136
                sprintf(buf,"%s_timediff_%s%s_triples_sqr.csv",analow,name,multibuf);
 
6137
                mprintf("      Saving %s squared temporal difference plot triples as \"%s\"...\n",anaup,buf);
 
6138
                df->m_p3DTimeDiffSqr->Write("",buf,"");
 
6139
                sprintf(buf,"%s_timediff_%s%s_matrix_sqr.csv",analow,name,multibuf);
 
6140
                mprintf("      Saving %s squared temporal difference plot matrix as \"%s\"...\n",anaup,buf);
 
6141
                df->m_p3DTimeDiffSqr->WriteCSV("",buf,"");
 
6142
                sprintf(buf,"%s_timediff_%s%s_sqr.nb",analow,name,multibuf);
 
6143
                mprintf("      Saving %s squared temporal difference plot Mathematica Notebook as \"%s\"...\n",anaup,buf);
 
6144
                df->m_p3DTimeDiffSqr->WriteMathematicaNb("",buf,"",false);
 
6145
                sprintf(buf,"%s_timediff_%s%s_sqr",analow,name,multibuf);
 
6146
                mprintf("      Saving %s squared temporal difference plot Gnuplot Input as \"%s.gp\"...\n",anaup,buf);
 
6147
                df->m_p3DTimeDiffSqr->WriteGnuplotInput("",buf,"",false);
 
6148
 
 
6149
                if (m_iTimeDiffDistSteps != 0)
 
6150
                {
 
6151
                        for (z=0;z<m_iTimeDiffDepth/m_iTimeDiffStride3D/m_iTimeDiffDistSteps;z++)
 
6152
                        {
 
6153
                                sprintf(buf,"%s_timediff_beforeafter_%s%s_tau%.3f_triples.csv",analow,name,multibuf,z*m_iTimeDiffStride3D*m_iTimeDiffDistSteps*g_fTimestepLength/1000.0);
 
6154
                                mprintf("      Saving %s before/after plot triples as \"%s\"...\n",anaup,buf);
 
6155
                                df->m_pTimeDiffDistPairs[z]->Write("",buf,"");
 
6156
                                sprintf(buf,"%s_timediff_beforeafter_%s%s_tau%.3f_matrix.csv",analow,name,multibuf,z*m_iTimeDiffStride3D*m_iTimeDiffDistSteps*g_fTimestepLength/1000.0);
 
6157
                                mprintf("      Saving %s before/after plot matrix as \"%s\"...\n",anaup,buf);
 
6158
                                df->m_pTimeDiffDistPairs[z]->WriteCSV("",buf,"");
 
6159
                                sprintf(buf,"%s_timediff_beforeafter_%s%s_tau%.3f.nb",analow,name,multibuf,z*m_iTimeDiffStride3D*m_iTimeDiffDistSteps*g_fTimestepLength/1000.0);
 
6160
                                mprintf("      Saving %s before/after plot Mathematica Notebook as \"%s\"...\n",anaup,buf);
 
6161
                                df->m_pTimeDiffDistPairs[z]->WriteMathematicaNb("",buf,"",false);
 
6162
                                sprintf(buf,"%s_timediff_beforeafter_%s%s_tau%.3f",analow,name,multibuf,z*m_iTimeDiffStride3D*m_iTimeDiffDistSteps*g_fTimestepLength/1000.0);
 
6163
                                mprintf("      Saving %s before/after plot Gnuplot Input as \"%s.gp\"...\n",anaup,buf);
 
6164
                                df->m_pTimeDiffDistPairs[z]->WriteGnuplotInput("",buf,"",false);
 
6165
                        }
 
6166
                }
 
6167
                for (z2=0;z2<=3;z2++)
 
6168
                {
 
6169
                        try { temp3DF = new C3DF(); } catch(...) { temp3DF = NULL; }
 
6170
                        if (temp3DF == NULL) NewException((double)sizeof(C3DF),__FILE__,__LINE__,__PRETTY_FUNCTION__);
 
6171
                        
 
6172
                        temp3DF->CopyFrom(df->m_pTimeDiffDist3DF);
 
6173
                        if (z2 != 0)
 
6174
                        {
 
6175
                                temp3DF->Smooth(z2);
 
6176
                                sprintf(buf,".s%d%s.plt",z2,multibuf);
 
6177
                        } else sprintf(buf,"%s.plt",multibuf);
 
6178
                        mprintf("    Saving 3D Plot as \"%s%s\"...\n",name,buf);
 
6179
                        temp3DF->WritePLT("",name,buf,false);
 
6180
 
 
6181
                        if (z2 != 0)
 
6182
                                sprintf(buf,".s%d%s.cube",z2,multibuf);
 
6183
                                        else sprintf(buf,"%s.cube",multibuf);
 
6184
                        mprintf("    Saving 3D Plot as \"%s%s\"...\n",name,buf);
 
6185
                        temp3DF->WriteCube("",name,buf,false);
 
6186
                }
 
6187
        }
 
6188
}
 
6189
 
 
6190
 
 
6191
void CObservation::CreateTimeDiff(CDF *df, int comb)
 
6192
{
 
6193
        int z2;
 
6194
        CxFloatArray *ptfa;
 
6195
 
 
6196
        if (m_bSelf)
 
6197
        {
 
6198
                for (z2=0;z2<((CMolecule*)g_oaMolecules[g_iFixMol])->m_laSingleMolIndex.GetSize()*comb;z2++)
 
6199
                {
 
6200
                        try { ptfa = new CxFloatArray("CObservation::CreateTimeDiff():ptfa"); } catch(...) { ptfa = NULL; }
 
6201
                        if (ptfa == NULL) NewException((double)sizeof(CxFloatArray),__FILE__,__LINE__,__PRETTY_FUNCTION__);
 
6202
                        
 
6203
                        if (g_iTrajSteps != -1)
 
6204
                        {
 
6205
                                ptfa->SetMaxSize((long)(g_iTrajSteps*1.1));
 
6206
                                ptfa->SetGrow((long)(g_iTrajSteps*0.1));
 
6207
                        } else ptfa->SetGrow(1000);
 
6208
                        df->m_oaTimeDiffBuf.Add(ptfa);
 
6209
                }
 
6210
        } else
 
6211
        {
 
6212
                for (z2=0;z2<((CMolecule*)g_oaMolecules[g_iFixMol])->m_laSingleMolIndex.GetSize()*((CMolecule*)g_oaMolecules[m_iShowMol])->m_laSingleMolIndex.GetSize()*comb;z2++)
 
6213
                {
 
6214
                        try { ptfa = new CxFloatArray("CObservation::CreateTimeDiff():ptfa"); } catch(...) { ptfa = NULL; }
 
6215
                        if (ptfa == NULL) NewException((double)sizeof(CxFloatArray),__FILE__,__LINE__,__PRETTY_FUNCTION__);
 
6216
                        
 
6217
                        if (g_iTrajSteps != -1)
 
6218
                        {
 
6219
                                ptfa->SetMaxSize((long)(g_iTrajSteps*1.1));
 
6220
                                ptfa->SetGrow((long)(g_iTrajSteps*0.1));
 
6221
                        } else ptfa->SetGrow(1000);
 
6222
                        df->m_oaTimeDiffBuf.Add(ptfa);
 
6223
                }
 
6224
        }
 
6225
}
 
6226
 
 
6227
 
 
6228
void CMSD::WriteSplit(const char *s)
 
6229
{
 
6230
        FILE *a;
 
6231
        int z, z2, z3;
 
6232
        CAF *af;
 
6233
 
 
6234
        a = OpenFileWrite(s,true);
 
6235
        mfprintf(a,"# tau [ps];  Total MSD [pm^2]");
 
6236
 
 
6237
        for (z=0;z<m_pAtomGroup->m_oaAtoms.GetSize();z++)
 
6238
                for (z2=0;z2<((CxIntArray*)m_pAtomGroup->m_oaAtoms[z])->GetSize();z2++)
 
6239
                        for (z3=0;z3<((CMolecule*)g_oaMolecules[m_iShowMol])->m_laSingleMolIndex.GetSize();z3++)
 
6240
                        {
 
6241
                                if (m_pAtomGroup->m_baRealAtomType[z] == g_iVirtAtomType)
 
6242
                                        mfprintf(a,";  Mol. %d #%d",z3+1,((CxIntArray*)m_pAtomGroup->m_oaAtoms[z])->GetAt(z2)+1);
 
6243
                                                else mfprintf(a,";  Mol. %d %s%d",z3+1,((CAtom*)g_oaAtoms[m_pAtomGroup->m_baRealAtomType[z]])->m_sName,((CxIntArray*)m_pAtomGroup->m_oaAtoms[z])->GetAt(z2)+1);
 
6244
                        }
 
6245
        mfprintf(a,"\n");
 
6246
 
 
6247
        for (z=0;z<m_pMSD->m_iResolution;z++)
 
6248
        {
 
6249
                mfprintf(a,"%f;  %f",m_pMSD->m_fMinVal+z*(m_pMSD->m_fMaxVal-m_pMSD->m_fMinVal)/m_pMSD->m_iResolution,m_pMSD->m_pBin[z]);
 
6250
 
 
6251
                for (z2=0;z2<m_pAtomGroup->m_iAtomGes;z2++)
 
6252
                        for (z3=0;z3<((CMolecule*)g_oaMolecules[m_iShowMol])->m_laSingleMolIndex.GetSize();z3++)
 
6253
                        {
 
6254
                                af = m_pSplitMSD[z2*((CMolecule*)g_oaMolecules[m_iShowMol])->m_laSingleMolIndex.GetSize()+z3];
 
6255
                                mfprintf(a,";  %f",af->m_pBin[z]);
 
6256
                        }
 
6257
                mfprintf(a,"\n");
 
6258
        }
 
6259
 
 
6260
        fclose(a);
 
6261
}