~ubuntu-branches/ubuntu/wily/travis/wily-proposed

« back to all changes in this revision

Viewing changes to src/pdf.cpp

  • Committer: Package Import Robot
  • Author(s): Daniel Leidert
  • Date: 2015-05-10 11:28:34 UTC
  • mfrom: (1.1.10)
  • Revision ID: package-import@ubuntu.com-20150510112834-7376w30r5uor41vf
Tags: 150205-1
* New upstream release.
* debian/control (Standards-Version): Bumped to 3.9.6.
* debian/copyright: Updated.

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
    TRAVIS - Trajectory Analyzer and Visualizer
3
3
    http://www.travis-analyzer.de/
4
4
 
5
 
    Copyright (c) 2009-2014 Martin Brehm
6
 
                  2012-2014 Martin Thomas
 
5
    Copyright (c) 2009-2015 Martin Brehm
 
6
                  2012-2015 Martin Thomas
7
7
 
8
8
    This file written by Martin Thomas.
9
9
 
29
29
#include "maintools.h"
30
30
#include "xobarray.h"
31
31
#include "xvector3.h"
 
32
#include "xstring.h"
32
33
 
33
 
#define BUF_SIZE 1024
 
34
//#define BUF_SIZE 1024
34
35
 
35
36
static CxVector3 g_normalVector;
36
37
static CxVector3 g_fixPoint;
38
39
static CxObArray g_pdfObserv;
39
40
 
40
41
CPDF::CPDF(int showMol) {
 
42
//      char buf[256];
 
43
        CxString buf;
 
44
 
41
45
        m_iShowMol = showMol;
42
46
        _showAtomGes = 0;
43
47
        
61
65
                        mprintf("    Which atom(s) to take from OM %s (e.g. \"C1,C3-5,H\", \"*\"=all)? [#2] ",((CMolecule*)g_oaMolecules[m_iShowMol])->m_sName);
62
66
                        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);
63
67
                        
64
 
                        char buf[256];
65
 
                        myget(buf);
 
68
                        myget(&buf);
66
69
                        if(strlen(buf) == 0) {
67
70
                                if(!_ag->ParseAtoms((CMolecule *)g_oaMolecules[m_iShowMol], "#2")) {
68
71
                                        eprintf("Weird error.\n");
135
138
}
136
139
 
137
140
void CPDF::finalize() {
 
141
        CxString filename;
 
142
 
138
143
        mprintf("    %.0f bin entries, %.0f out of bin range (%.2f percent).\n", _df->m_fBinEntries, _df->m_fSkipEntries, ZeroDivide(_df->m_fSkipEntries, _df->m_fBinEntries + _df->m_fSkipEntries) * 100.0f);
139
144
        _df->CalcMeanSD();
140
145
        mprintf("    Mean value: %10G pm    Standard deviation: %10G pm\n", _df->m_fMean, _df->m_fSD);
143
148
        mprintf("    Scaling Density Profile to uniform density...\n");
144
149
        _df->MultiplyBin((g_normalVector[0] * g_normalVector[0] * g_fBoxX + g_normalVector[1] * g_normalVector[1] * g_fBoxY + g_normalVector[2] * g_normalVector[2] * g_fBoxZ) * m_iResolution / (_maxDist-_minDist) / g_iSteps / ((CMolecule *)g_oaMolecules[m_iShowMol])->m_laSingleMolIndex.GetSize() / _showAtomGes);
145
150
        
146
 
        char filename[BUF_SIZE];
 
151
/*      char filename[BUF_SIZE];
147
152
 
148
153
#ifdef TARGET_WINDOWS
149
154
        _snprintf(filename, BUF_SIZE, "dprof_%s.csv", m_sName);
151
156
        snprintf(filename, BUF_SIZE, "dprof_%s.csv", m_sName);
152
157
#else
153
158
        sprintf(filename, "dprof_%s.csv", m_sName);
154
 
#endif
155
 
 
156
 
        mprintf("    Saving density profile as \"%s\"...\n", filename);
 
159
#endif*/
 
160
 
 
161
        filename.sprintf("dprof_%s.csv", m_sName);
 
162
 
 
163
        mprintf("    Saving density profile as \"%s\"...\n", (const char*)filename);
157
164
        _df->Write("", filename, "", true);
158
165
 
159
 
#ifdef TARGET_WINDOWS
 
166
/*#ifdef TARGET_WINDOWS
160
167
        _snprintf(filename, BUF_SIZE, "dprof_%s.agr", m_sName);
161
168
#elif defined TARGET_LINUX
162
169
        snprintf(filename, BUF_SIZE, "dprof_%s.agr", m_sName);
163
170
#else
164
171
        sprintf(filename, "dprof_%s.agr", m_sName);
165
 
#endif
166
 
 
167
 
        mprintf("    Saving density profile AGR as \"%s\"...\n", filename);
 
172
#endif*/
 
173
 
 
174
        filename.sprintf("dprof_%s.agr", m_sName);
 
175
 
 
176
        mprintf("    Saving density profile AGR as \"%s\"...\n", (const char*)filename);
168
177
        _df->WriteAgr("", filename, "", m_sName, true);
169
178
}
170
179
 
 
180
 
171
181
void CPDF::buildAtomList(CSingleMolecule *sm, CxIntArray *array) {
172
182
        int i, j;
173
183
        
181
191
        }
182
192
}
183
193
 
 
194
 
184
195
void CPDF::addToDF(float value) {
185
196
        _df->AddToBin(value);
186
197
}
187
198
 
 
199
 
188
200
void CPDF::buildName() {
189
 
        char tmp[BUF_SIZE];
 
201
//      char tmp[BUF_SIZE];
 
202
        CxString tmp;
190
203
        
191
204
        // Check for overflow is missing!!!
192
 
        tmp[0] = 0;
 
205
/*      tmp[0] = 0;
193
206
        if(m_iDeriv != 0) {
194
207
                sprintf(tmp, "deriv%d_", m_iDeriv);
195
208
        }
196
209
        strcat(tmp, "[");
 
210
        strcat(tmp, ((CMolecule *)g_oaMolecules[m_iShowMol])->m_sName);
 
211
        strcat(tmp, "_");
197
212
        strcat(tmp, _ag->m_sName);
198
 
        strcat(tmp, "]");
 
213
        strcat(tmp, "]");*/
 
214
 
 
215
        tmp.sprintf("");
 
216
        if(m_iDeriv != 0) {
 
217
                tmp.sprintf("deriv%d_", m_iDeriv);
 
218
        }
 
219
        tmp.strcat("[");
 
220
        tmp.strcat(((CMolecule *)g_oaMolecules[m_iShowMol])->m_sName);
 
221
        tmp.strcat("_");
 
222
        tmp.strcat(_ag->m_sName);
 
223
        tmp.strcat("]");
199
224
        
200
225
        try { m_sShortName = new char[1]; } catch(...) { m_sShortName = NULL; }
201
226
        if(m_sShortName == NULL) NewException((double)sizeof(char), __FILE__, __LINE__, __PRETTY_FUNCTION__);
210
235
 
211
236
CPDFObservation::CPDFObservation() {
212
237
        int i;
 
238
        CxString buf, buf2;
213
239
        
214
240
        m_pConditions = NULL;
215
241
        m_bTimeDev = false;
217
243
        m_bOthers = true;
218
244
        
219
245
        if(g_oaMolecules.GetSize() > 1) {
220
 
                char buf[BUF_SIZE], buf2[BUF_SIZE];
 
246
/*              char buf[BUF_SIZE], buf2[BUF_SIZE];
221
247
                size_t remaining = BUF_SIZE;
222
248
                
223
249
#ifdef TARGET_WINDOWS
226
252
                remaining -= snprintf(buf, remaining, "    Which molecule should be observed (");
227
253
#else
228
254
                remaining -= sprintf(buf, "    Which molecule should be observed (");
229
 
#endif
 
255
#endif*/
 
256
 
 
257
                buf.sprintf("    Which molecule should be observed (");
230
258
                
231
259
                for(i = 0; i < g_oaMolecules.GetSize(); i++) {
232
 
                        if(remaining < 1)
 
260
 
 
261
/*                      if(remaining < 1)
233
262
                                break;
234
263
 
235
264
#ifdef TARGET_WINDOWS
241
270
#endif
242
271
 
243
272
                        strncat(buf, buf2, remaining - 1);
244
 
                        remaining -= length;
 
273
                        remaining -= length;*/
 
274
 
 
275
                        buf2.sprintf("%s=%d", ((CMolecule *)g_oaMolecules[i])->m_sName, i+1);
 
276
                        buf.strcat(buf2);
 
277
 
245
278
                        if(i < g_oaMolecules.GetSize() - 1) {
246
279
 
247
 
#ifdef TARGET_WINDOWS
 
280
/*#ifdef TARGET_WINDOWS
248
281
                                length = _snprintf(buf2, remaining, ", ");
249
282
#elif defined TARGET_LINUX
250
283
                                length = snprintf(buf2, remaining, ", ");
253
286
#endif
254
287
 
255
288
                                strncat(buf, buf2, remaining - 1);
256
 
                                remaining -= length;
 
289
                                remaining -= length;*/
 
290
 
 
291
                                buf2.sprintf(", ");
 
292
                                buf.strcat(buf2);
257
293
                        }
258
294
                }
259
 
                strncat(buf, ")? ", remaining - 1);
 
295
//              strncat(buf, ")? ", remaining - 1);
 
296
                buf.strcat(")? ");
 
297
 
260
298
                m_iShowMol = AskRangeInteger_ND(buf, 1, g_oaMolecules.GetSize()) - 1;
261
299
        } else {
262
300
                m_iShowMol = 0;