ConfigFile.cpp 17.9 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
/*
# Copyright 2016-2018 The NOMAD Developers Group
 #
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
 # You may obtain a copy of the License at
 #
 #     http://www.apache.org/licenses/LICENSE-2.0
 #
 # Unless required by applicable law or agreed to in writing, software
 # distributed under the License is distributed on an "AS IS" BASIS,
 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 # See the License for the specific language governing permissions and
 # limitations under the License.
*/


18
#include <algorithm>
19
#include <errno.h>
20
#include <string.h>
21
22
23
24

#include "ConfigFile.h"
#include "atoms.hpp"
#include "eprintf.h"
25
#include "polyhedron.h"
26
27
28
29
30
31
32
33
34

const char * PATH;
const char * SCREENSHOT;
int ISOS;
int TIMESTEPS;
float **isocolours; // [ISOS][4];
const char **plyfiles;
float **translations;
float userpos[3];
35
36
float scaling;
float markerscaling;
37
38
39
40

float BACKGROUND[3];
int* numAtoms; //[timesteps]
float **atoms; //[timesteps][numAtoms[i]*4] //xyzu, u=atom number
41
42
bool fixedAtoms; 

43
44
float atomScaling;
std::vector<float> *clonedAtoms;
45
46
std::vector<int> bonds;
int *numBonds;
47
bool displaybonds;
48
49
50
float bondscolours[4];
float atomtrajectorycolour[4];

51
52
53
54
55
56
57
58
59
int numClonedAtoms;
int *basisvectorreps;

bool showTrajectories;
std::vector<int> atomtrajectories;
std::vector<std::vector<int>> atomtrajectoryrestarts;

float abc[3][3]; //basis vectors
bool has_abc = false;
60
61
62
bool displayunitcell;
float supercell[3];
int voxelSize[3];
63
64
float unitcellcolour[4];
float supercellcolour[4];
65

66
67
float infolinecolour[4];

68
int repetitions[3];
69
Solid *solid;
70

71
72
bool saveStereo;
int screenshotdownscaling;
73
bool hapticFeedback;
74
bool showcontrollers;
75
76
77
78
bool gazenavigation;
int transparencyquality;
float nearclip, farclip;

79
80
81
82
//markers such as hole positions and electron positions
float ** markers;
float ** markercolours;
float cubetrans[3];
83

84
85
float animationspeed;
float movementspeed;
86

87
88
std::vector<information> info;

89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
const char * loadConfigFileErrors[] =
{
	"All Ok",//0
	"file could not be opened", //-1
	"unrecognized parameter",//-2
	"values with no previous iso", //-3
	"colours with no previous iso",//-4
	"translations with no previous correct iso",//-5
	"Missing isos and xyzfile",//-6
	"missing values",//-7
	"timesteps from config file and from atom file do not match",//-8, unused, now minimum is used
	"isos parameter specified twice",//-9
	"Error reading unit cell parameters", //-10
	"Error reading repetitions",//-11
	"Non-periodic, but repetitions requested", //-12
	"No basis vectors, but repetitions requested", //-13
	"Error loading config file",// -14
106
	"Error reading atomglyph", //-15
107
	"Error reading token", //-16
108
109
	"markers with no previous correct timesteps parameter", //-17
	"markercolours with no previous correct timesteps parameter", //-18
110
	"Error reading atomcolour", // -19
111
	"Error reading newatom", //-20
112
	"Error loading xyz file, add 100 to see the error",//<-100
113
114
115
	"Error loading cube file, add 200 to see the error",//<-200
	"Error loading encyclopedia json file, add 300 to see the error",//<-300
	"Error loading analytics json file, add 400 to see the error",//<-400
116
117
118
119
120
121
122
123
124
125
126
127
};

void updateTIMESTEPS (int timesteps)
{
if (TIMESTEPS==0)
	TIMESTEPS=timesteps;
else
	TIMESTEPS=std::min(TIMESTEPS, timesteps);
}

int readString(FILE *f, char *s)
{
128
	char s2[2048];
129
	int r, c;
130
	r = fscanf(f, "%2047s", s2);
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
	if (r!=1)
		return -1;
	if (s2[0]!='"') {
		strcpy(s, s2);
		return 0;
	} else {
		strcpy(s, s2+1); //skip "
		size_t l = strlen(s);
		if (s[l-1] == '"') {
			s[l-1] = '\0';
			return 0;
		}
		else {
			char *p = s2;
			do {
				c = fgetc(f);
				*p++ = c;
			} while (c != EOF && c != '"');
			*(p-1) = '\0';
			strcat(s, s2);
		}
	}
	return 0;
}

void fixFile(char * file)
{
#ifdef WIN32
	const char c='\\';
#else
	const char c='/';
#endif
while (*file!='\0') {
	if (*file=='/' || *file=='\\')
		*file=c;
	file++;
}
}

170
void initState()
171
{
172
	BACKGROUND[0] = 0.95f;
173
174
175
176
177
178
179
180
181
	BACKGROUND[1] = 0.95f;
	BACKGROUND[2] = 0.95f;
	SCREENSHOT="C:\\temp\\frame";
	ISOS = 0;
	TIMESTEPS=0;
	PATH=strdup("");
	numAtoms=0;
	atomScaling=1;
	clonedAtoms=0;
182
	fixedAtoms=false;
183
	bonds.clear();
184
	displaybonds=false;
185
186
187
	showTrajectories = false;
	basisvectorreps=0;
	numClonedAtoms=0;
188
	has_abc=false;
189
190
191
192
	for (int i=0;i<3;i++)
		repetitions[i]=1;
	for (int i=0;i<3;i++)
		userpos[i] = 0;
193
194
	for (int i=0;i<3;i++)
		supercell[i] = 1;
195
	solid=0;
196

197
198
199
200
201
202
203
204
205
206
	markers=nullptr;
	markercolours=nullptr;
	displayunitcell=false;
	scaling =1;
	markerscaling=0.8;
	for (int i=0;i<3;i++)
		cubetrans[i]=0;
	translations=nullptr;
	for (int i=0;i<3;i++)
		voxelSize[i]=-1;
207
208
	saveStereo=false;
	screenshotdownscaling=1;
209
	hapticFeedback=false;
210
	showcontrollers=false;
211
	gazenavigation=false;
212
	inv_abc_init=false;
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234

	transparencyquality=12;
	nearclip=0.2f;
	farclip=200.f;

	for (int i=0;i<4;i++)
		unitcellcolour[i]=1.0f;
	
	supercellcolour[0]=0.0f;
	supercellcolour[1]=1.0f;
	supercellcolour[2]=1.0f;
	supercellcolour[3]=1.0f;

	bondscolours[0]=0.5f;
	bondscolours[1]=0.5f;
	bondscolours[2]=1.0f;
	bondscolours[3]=1.0f;

	atomtrajectorycolour[0]=1.0f;
	atomtrajectorycolour[1]=0.0f;
	atomtrajectorycolour[2]=0.0f;
	atomtrajectorycolour[3]=1.0f;
235
236
237

	animationspeed=1.0f;
	movementspeed=1.0f;
238
239
240
241
242

	infolinecolour[0] = 1.0f;
	infolinecolour[1] = 1.0f;
	infolinecolour[2] = 0.0f;
	infolinecolour[3] = 1.0f;
243
244
245
246
247
248
249
250
251
252
253
254
}

int loadConfigFile(const char * f)
{
	//default values
	//eprintf ("load config file start");
	bool nonperiodic=false;
	char base_url[1024]="http://enc-testing-nomad.esc.rzg.mpg.de/v1.0/materials/";
	char material[1024]="";
	initState();
	char *token=0;

255
256
257
258
	FILE *F = fopen(f, "r");
	if (F == 0)
	{
		eprintf( "Could not open config file %s\n", f);
259
		eprintf("Error: %d", errno);
260
261
262
263
264
265
266
267
		return -1;
	}
	char s[100];
	int r;
	while (!feof(F)) {
		r=fscanf(F, "%99s", s);
		if (r <= 0)
			continue;
268
269
		if ((unsigned char)s[0]==0xef && (unsigned char)s[1]==0xbb && (unsigned char)s[2]==0xbf) //utf bom
			strcpy (s, s+3);
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
		if (s[0] == '#') {//comment
			discardline(F);
			continue;
		}
		if (!strcmp(s, "timesteps")) {
			int timesteps;
			r = fscanf(F, "%d", &timesteps);
			if (TIMESTEPS==0)
				TIMESTEPS=timesteps;
			else
				TIMESTEPS=std::min(TIMESTEPS, timesteps);
		}
		else if (!strcmp(s, "isos")) {
			if (ISOS!=0) 
				return -9;
			r = fscanf(F, "%d", &ISOS);
			plyfiles = new const char*[ISOS];
			isocolours = new float*[ISOS];
			translations = new float*[ISOS];
			for (int i = 0; i < ISOS; i++) {
				plyfiles[i] = strdup("");
				isocolours[i] = new float[4];
				translations[i] = new float[3];
				//default values
				for (int j = 0; j < 4; j++)
					isocolours[i][j] = 1.f;
				for (int j = 0; j < 3; j++)
					translations[i][j] = 0.f;
			}
		}
		else if (!strcmp(s, "values")) {
			if (ISOS == 0) {
				eprintf( "values with no previous correct isos parameter\n");
				fclose(F);
				return -3;
			}
			for (int i = 0; i < ISOS; i++) {
				r=readString(F, s);
				if (r!=0)
					return -14;
				free ((void*)(plyfiles[i]));
				plyfiles[i] = strdup(s);
			}

		}
		else if (!strcmp(s, "colours")) {
			if (ISOS == 0) {
				eprintf( "colours with no previous correct isos parameter\n");
				return -4;
			}
			for (int i = 0; i < ISOS; i++) {
				for (int j = 0; j < 4; j++)
					r = fscanf(F, "%f", &(isocolours[i][j]));
				//if (r==0)
			}
		}
		else if (!strcmp(s, "path")) {
			r=readString(F, s);
			if (r!=0)
				return -14;			
			free((void*)PATH);
			PATH = strdup(s);
		}
		else if (!strcmp(s, "background")) {
			for (int i = 0; i < 3; i++)
				r = fscanf(F, "%f", BACKGROUND + i);
		}
		else if (!strcmp(s, "translations")) {
			if (ISOS == 0) {
				eprintf( "translations with no previous correct isos parameter\n");
				fclose(F);
				return -5;
			}
			for (int i=0;i<ISOS;i++)
				for (int j = 0; j < 3; j++) {
					r = fscanf(F, "%f", &(translations[i][j]));
				}
		}
		else if (!strcmp(s, "userpos")) {
			for (int j = 0; j < 3; j++) {
				r = fscanf(F, "%f", &(userpos[j]));
			}
		}
		else if (!strcmp(s, "screenshot")) {
			r=readString(F, s);
			if (r!=0)
				return -14;
			SCREENSHOT = strdup(s);
		}
		else if (!strcmp(s, "xyzfile")||!strcmp(s, "atomfile")) {
			r=readString(F, s);
			if (r!=0)
				return -14;
			int timesteps;
			char file[256];
			sprintf (file, "%s%s", PATH, s);
			fixFile(file);
			int e;
			e=readAtomsXYZ(file, &numAtoms, &timesteps, &atoms);
			if (e<0)
				return e-100;
			updateTIMESTEPS (timesteps);
372
			//eprintf ("After read of xyzfile, numatoms 0 =%d", numAtoms[0]);
373
374
375
376
377
		}
		else if (!strcmp(s, "cubefile")) {
			r=readString(F, s);
			if (r!=0)
				return -14;
378
			int timesteps=TIMESTEPS;
379
380
381
382
383
384
385
386
387
388
389
390
391
			char file[256];
			sprintf(file, "%s%s", PATH, s);
			fixFile(file);
			int e;
			e = readAtomsCube(file, &numAtoms, &timesteps, &atoms);
			if (e<0)
				return e - 200;
			updateTIMESTEPS (timesteps);
			//	return -8;
		}
		else if (!strcmp(s, "atomscaling")) {
			r = fscanf(F, "%f", &atomScaling);
		}
392
393
394
		else if (!strcmp(s, "scaling")) {
			r = fscanf(F, "%f", &scaling);
		}
395
396
397
398
399
400
401
402
403
		else if (!strcmp(s, "abc")) {
			for (int i=0;i<3;i++)
				for (int j=0;j<3;j++) {
					r = fscanf(F, "%f", &(abc[i][j]));
					if (r!=1)
						return -10;
				}
			has_abc = true;
		}
404
		else if (!strcmp(s, "json") || !strcmp (s, "encyclopediajson")) {
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
			r=readString(F, s);
			if (r!=0)
				return -14;
			char file[256];
			sprintf(file, "%s%s", PATH, s);
			fixFile(file);
			int e;
			int timesteps;
			//rgh fixme, we know only one
			e = readAtomsJson (file, &numAtoms, &timesteps, &atoms, abc, &clonedAtoms);
			if (e<0)
				return e-300;
			numClonedAtoms=clonedAtoms[0].size()/4;
			has_abc=true;
			updateTIMESTEPS (timesteps);
420
421
422
423
424
425
426
427
428
429
430
431
432
433
		}
		else if (!strcmp(s, "analyticsjson")) {
			r = readString(F, s);
			if (r != 0)
				return -14;
			char file[256];
			sprintf(file, "%s%s", PATH, s);
			fixFile(file);
			int e;
			int timesteps;
			//rgh fixme, we know only one
			e = readAtomsAnalyticsJson(file, &numAtoms, &timesteps, &atoms, abc, &clonedAtoms);
			if (e<0)
				return e - 400;
434
435
436
437
438
439

			if (has_abc)
				numClonedAtoms = clonedAtoms[0].size() / 4;
			else
				numClonedAtoms=0;

440
441
			updateTIMESTEPS(timesteps);
		}
442
443
444
445
446
447
448
449
450
451
452
453
454
455
		else if (!strcmp(s, "baseurl")) {
			r=readString (F, base_url);
			if (r!=0)
				return -14;
		} 
		else if (!strcmp(s, "jsonurl")) {
			int e;
			int timesteps;
			r=readString (F, material);
			if (r!=0)
				return -14;
			char url[2048];
			sprintf (url, "%s%s", base_url, material);
			//rgh fixme, we know only one
456
			//eprintf ("load config file start, before readAtomsJsonURL");
457
			e = readAtomsJsonURL (url, &numAtoms, &timesteps, &atoms, abc, &clonedAtoms, token);
458
			//eprintf ("load config file start, after readAtomsJsonURL");
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
			if (e<0)
				return e-300;
			numClonedAtoms=clonedAtoms[0].size()/4;
			has_abc=true;
			updateTIMESTEPS (timesteps);
		}
		else if (!strcmp(s, "showtrajectory")) {
			showTrajectories = true;
			int atom;
			while (1 == (r = fscanf(F, "%d", &atom))) {
				atomtrajectories.push_back(atom - 1);
			}
			if (atomtrajectories.size() == 0) //empty showtrajectory
				showTrajectories = false;
		} else if (!strcmp(s, "nonperiodic")) {
			nonperiodic=true;
		} else if (!strcmp(s, "repetitions")) {
			for (int j=0;j<3;j++) {
					r = fscanf(F, "%d", repetitions+j);
					if (r!=1)
						return -11;
			}
481
482
483
484
485
486
487
488
489
490
		} else if (!strcmp(s, "atomglyph")) {
			r=fscanf (F, "%s", s);
			if (r==0)
				return -15;
			if (!strcmp(s, "icosahedron"))
				solid=new Solid(Solid::Type::Icosahedron);
			else if(!strcmp(s, "octahedron"))
				solid=new Solid(Solid::Type::Octahedron);
			else if(!strcmp(s, "tetrahedron"))
				solid=new Solid(Solid::Type::Tetrahedron);
491
492
493
494
495
			else if(!strcmp(s, "sphere")) {
				int subd;
				r=fscanf (F, "%d", &subd);
				solid=new Solid(Solid::Type::Sphere, subd);
			}
496
497
			else
				return -15;
498
499
500
501
502
503
504
		} else if (!strcmp (s, "token")) {
			if (token)
				delete (token);
			token=new char [2048];
			r=readString (F, token);
			if (r!=0)
				return -16;
505
506
		} else if (!strcmp (s, "fixedatoms")) {
			fixedAtoms=true;
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
		} else if (!strcmp (s, "markers")) {
			if (TIMESTEPS == 0) {
				eprintf( "markers with no previous correct timesteps parameter\n");
				fclose(F);
				return -17;
			}
			markers=new float* [TIMESTEPS];
			for (int i=0;i<TIMESTEPS;i++) {
				markers[i]=new float[3];
				//in abc coordinates if they exist
				float tmp[3];
				for (int j = 0; j < 3; j++) {
					r = fscanf(F, "%f", &(tmp[j]));
				}
				if (has_abc) {
					//for (int s=0;s<3;s++) 
					//	tmp[s]-=translations[0][s]; //using translation of iso 0
					//check if coordinates are outside of cell
525
526
527
528
529
					if (translations) {
						for (int s=0;s<3;s++) {
							while (tmp[s]<-translations[0][s])
								tmp[s]+=supercell[2-s];
						}
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
					}
					for (int s=0;s<3;s++) {
						markers[i][s]=tmp[2]*abc[0][s]+tmp[1]*abc[1][s]+tmp[0]*abc[2][s]; //hole positions seem to be in zyx
					}
				}
				else
					for (int s=0;s<3;s++)
						markers[i][s]=tmp[s];

			}
		} else if (!strcmp (s, "markercolours")) {
		if (TIMESTEPS == 0) {
			eprintf( "markecolours with no previous correct timesteps parameter\n");
			fclose(F);
			return -18;
		}
		markercolours=new float* [TIMESTEPS];
		for (int i=0;i<TIMESTEPS;i++) {
			markercolours[i]=new float[4];
			for (int j = 0; j < 4; j++) {
				r = fscanf(F, "%f", &(markercolours[i][j]));
			}
		}
		} else if (!strcmp (s, "displaybonds")) {
			displaybonds=true;
555
556
557
		} else if (!strcmp (s, "atomcolour")) {
			char atom [100];
			float rgb[3];
558
			r = fscanf(F, "%s %f %f %f", atom, rgb, rgb + 1, rgb + 2);
559
560
561
562
563
564
565
566
567
568
569
			if (r!=4) {
				eprintf ("Error loading atom colour");
				return -19;
			}
			int a=findAtom(atom);
			if (a==-1) {
				eprintf ("atomcolour, unknown atom type %s", atom);
				return -19;
			}
			for (int i=0;i<3;i++)
				atomColours[a][i]=rgb[i];
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
		} else if (!strcmp (s, "newatom")) {
			char atom [100];
			float rgb[3];
			float size;
			r = fscanf(F, "%s %f %f %f %f", atom, rgb, rgb + 1, rgb + 2, &size);
			if (r!=5) {
				eprintf ("Error loading newatom");
				return -20;
			}
			int a=findAtom(atom);
			if (a!=-1) {
				if (a<atomsInPeriodicTable) {
					for (int i=0;i<3;i++)
						atomColours[a][i]=rgb[i];
					atomColours[a][3]=size;
				} else {
					for (int i=0;i<3;i++)
						extraAtomData[a-atomsInPeriodicTable][i]=rgb[i];
					extraAtomData[a-atomsInPeriodicTable][3]=size;
				}
			} else { //new
				extraAtomNames.push_back(strdup(atom));
				extraAtomData.push_back(new float[4]);
				float *e=extraAtomData.back();
				for (int i=0;i<3;i++)
					e[i]=rgb[i];
				e[3]=size;
			}
598
599
600
601
		} else if (!strcmp (s, "markerscaling")) {
			r = fscanf(F, "%f", &markerscaling);
		} else if (!strcmp (s, "displayunitcell")) {
			displayunitcell=true;
602
603
604
605
606
607
		} else if (!strcmp (s, "stereoscreenshot")) {
			saveStereo=true;
		} else if (!strcmp (s, "screenshotdownscaling")) {
			r= fscanf(F, "%d", &screenshotdownscaling);
			if (r<1)
				eprintf ("Error reading screenshotdownscaling value");
608
609
		} else if (!strcmp (s, "hapticfeedback")) {
			hapticFeedback=true;
610
611
		} else if (!strcmp (s, "supercell")) {
			r=fscanf (F, "%f %f %f", supercell, supercell+1, supercell+2);
612
613
			if (r<3)
				eprintf ("Error reading supercell value");
614
615
		} else if (!strcmp (s, "showcontrollers")) { 
			showcontrollers=true;
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
		} else if (!strcmp (s, "gazenavigation")) { 
			gazenavigation=true;
		} else if (!strcmp (s, "transparencyquality")) {
			r=fscanf (F, "%d", &transparencyquality);
			if (r<1)
				eprintf ("Error reading transparencyquality value");
		} else if (!strcmp (s, "clippingplanes")) {
			r=fscanf (F, "%f %f", &nearclip, &farclip);
			if (r<2)
				eprintf ("Error reading clippingplanes values");
		}else if (!strcmp (s, "bondscolour")) {
			r=fscanf (F, "%f %f %f", bondscolours, bondscolours+1, bondscolours+2);
			if (r<3)
				eprintf ("Error reading bondscolour value");
		}else if (!strcmp (s, "unitcellcolour")) {
			r=fscanf (F, "%f %f %f", unitcellcolour, unitcellcolour+1, unitcellcolour+2);
			if (r<3)
				eprintf ("Error reading unitcellcolour value");
		}else if (!strcmp (s, "supercellcolour")) {
			r=fscanf (F, "%f %f %f", supercellcolour, supercellcolour+1, supercellcolour+2);
			if (r<3)
				eprintf ("Error reading supercellcolour value");
		}else if (!strcmp (s, "atomtrajectorycolour")) {
			r=fscanf (F, "%f %f %f", atomtrajectorycolour, atomtrajectorycolour+1, atomtrajectorycolour+2);
			if (r<3)
				eprintf ("Error reading atomtrajectorycolour value");
642
643
644
645
		}else if (!strcmp (s, "infolinecolour")) {
			r=fscanf (F, "%f %f %f", infolinecolour, infolinecolour+1, infolinecolour+2);
			if (r<3)
				eprintf ("Error reading atomtrajectorycolour value");
646
647
648
649
650
651
652
653
		} else if (!strcmp (s, "animationspeed")) {
			r=fscanf (F, "%f", &animationspeed);
			if (r<1)
				eprintf ("Error reading animationspeed");
		} else if (!strcmp (s, "movementspeed")) {
			r=fscanf (F, "%f", &movementspeed);
			if (r<1)
				eprintf ("Error reading movementspeed");
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
#ifdef WIN32
		} else if (!strcmp (s, "info")) {
			information i;
			r=fscanf (F, "%f %f %f %f %d", i.pos, i.pos+1, i.pos+2, &(i.size), &(i.atom));
			if (r<5)
				eprintf ("Error reading info");
			r=readString(F, s);
			if (r!=0)
				eprintf ("Error reading info");
			char file[256];
			sprintf (file, "%s%s", PATH, s);
			i.filename=strdup(file);
			//i.tex=LoadPNG(i.filename); //opengl not initialized yet
			info.push_back(i);
#endif
669
670
671
		} else if (!strcmp (s, "\x0d")) { //discard windows newline (problem in Sebastian Kokott's phone (?!)
			continue;
		} else {
672
			eprintf( "Unrecognized parameter %s\n", s);
673
674
			for (int i=0;i<strlen(s);i++)
				eprintf ("<%d>", s[i]);
675
676
677
678
679
680
681
682
			fclose(F);
			return -2;
		}
	}

//verification and additional processing
	fclose(F);

683
	/*if (ISOS == 0 && numAtoms==0) {
684
685
		eprintf( "Missing isos and atomfile parameter\n");
		return -6;
686
	} */
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
	if (ISOS !=0 && plyfiles[0] == 0) {
		eprintf( "Missing values parameter\n");
		fclose(F);
		return -7;
	}
	if (nonperiodic) {
		numClonedAtoms=0;
		if (repetitions[0]!=1 ||repetitions[1]!=1 ||repetitions[2]!=1)
			return -12;
	}
	if (repetitions[0]!=1 ||repetitions[1]!=1 ||repetitions[2]!=1) {
		if (!has_abc)
			return (-13);
		numClonedAtoms=0;
	}

	if (showTrajectories && atomtrajectories[0]<0) {
		atomtrajectories.clear();
		for (int i=0;i<*numAtoms;i++)
			atomtrajectories.push_back(i);
	}
708
709
710
711
712

	//chemical bonds
	//if (numAtoms) {
	//}

713
	//eprintf ("Before returning, numatoms 0 =%d", numAtoms[0]);
714
	return 0;
715
}