FOX/ObjCryst++  1.10.X (development)
ObjCryst/IO.cpp
1 /* ObjCryst++ Object-Oriented Crystallographic Library
2  (c) 2000-2006 Vincent Favre-Nicolin vincefn@users.sourceforge.net
3  2000-2001 University of Geneva (Switzerland)
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with this program; if not, write to the Free Software
17  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19 /*
20 * source file for XMLInput/XMLOutput in ObjCryst++
21 *
22 */
23 
24 #include <stdio.h>//for sprintf
25 
26 #include "ObjCryst/ObjCryst/General.h"
27 #include "ObjCryst/ObjCryst/IO.h"
28 #include "ObjCryst/RefinableObj/IO.h"
29 #include "ObjCryst/RefinableObj/GlobalOptimObj.h"
30 //#include "ObjCryst/ObjCryst/SpaceGroup.h"
31 #include "ObjCryst/ObjCryst/Scatterer.h"
32 #include "ObjCryst/ObjCryst/Crystal.h"
33 #include "ObjCryst/ObjCryst/ZScatterer.h"
34 //#include "ObjCryst/ObjCryst/ScatteringData.h"
35 #include "ObjCryst/ObjCryst/ScatteringPower.h"
36 #include "ObjCryst/ObjCryst/ScatteringPowerSphere.h"
37 #include "ObjCryst/ObjCryst/Atom.h"
38 #include "ObjCryst/ObjCryst/DiffractionDataSingleCrystal.h"
39 #include "ObjCryst/ObjCryst/PowderPattern.h"
40 #include "ObjCryst/Quirks/VFNStreamFormat.h"
41 #include "ObjCryst/ObjCryst/Molecule.h"
42 
43 #include <iostream>
44 #include <fstream>
45 #include <sstream>
46 #include <cstdlib>
47 #include "boost/format.hpp"
48 
49 //#define USE_BACKGROUND_MAXLIKE_ERROR
50 
51 namespace ObjCryst
52 {
54 //
55 // Global functions
56 //
58 
59 float string2floatC(const string &s)
60 {
61  float v=0;
62  stringstream ss(s);
63  ss.imbue(std::locale::classic());
64  ss>>v;
65  return v;
66 }
67 
68 float InputFloat(istream &is, const char endchar)
69 {
70  float f;
71  // Get rid of spaces, returns etc...
72  while(0==isgraph(is.peek())) is.get();
73  stringstream tmp;
74  char c;
75  while((endchar!=is.peek())&&(' '!=is.peek()))
76  {
77  is.get(c) ;
78  // Explicit typecasting to char otherwise it is understood as an integer number from type charT...
79  tmp<<(char)(tolower(c)) ;
80  }
81  if(tmp.str().find("nan")!=string::npos)
82  {
83  VFN_DEBUG_MESSAGE("InputFloat(..):"<<tmp.str()<<" -> NAN ! -> 1",9);
84  return 1;
85  }
86  if(tmp.str().find("inf")!=string::npos)
87  {
88  VFN_DEBUG_MESSAGE("InputFloat(..):"<<tmp.str()<<" -> INF ! -> 1",9);
89  return 1;
90  }
91  tmp.imbue(std::locale::classic());
92  tmp>>f;
93  VFN_DEBUG_MESSAGE("InputFloat(..):"<<f<<","<<is.good(),3);
94  return f;
95 }
96 
97 bool ISNAN_OR_INF(REAL r)
98 {
99  #if defined(_MSC_VER) || defined(__BORLANDC__)
100  return _isnan(r) || (!_finite(r));
101  #else
102  return (isnan(r)!=0) || (isinf(r)!=0);
103  #endif
104 }
105 
106 void XMLCrystFileSaveGlobal(const string & filename)
107 {
108  VFN_DEBUG_ENTRY("XMLCrystFileSaveGlobal(filename)",5)
109 
110  ofstream out(filename.c_str());
111  if(!out){};//:TODO:
113  out.close();
114  VFN_DEBUG_EXIT("XMLCrystFileSaveGlobal(filename):End",5)
115 }
116 
117 void XMLCrystFileSaveGlobal(ostream &out)
118 {
119  VFN_DEBUG_ENTRY("XMLCrystFileSaveGlobal(ostream)",5)
120  out.imbue(std::locale::classic());
121  XMLCrystTag tag("ObjCryst");
122  time_t date=time(0);
123  char strDate[40];
124  strftime(strDate,sizeof(strDate),"%Y-%m-%dT%H:%M:%S%Z",gmtime(&date));//%Y-%m-%dT%H:%M:%S%Z
125  tag.AddAttribute("Date",strDate);
126  tag.AddAttribute("Revision","1280");
127  out<<tag<<endl;
128 
129  for(int i=0;i<gCrystalRegistry.GetNb();i++)
130  gCrystalRegistry.GetObj(i).XMLOutput(out,1);
131 
132  for(int i=0;i<gDiffractionDataSingleCrystalRegistry.GetNb();i++)
133  gDiffractionDataSingleCrystalRegistry.GetObj(i).XMLOutput(out,1);
134 
135  for(int i=0;i<gPowderPatternRegistry.GetNb();i++)
136  gPowderPatternRegistry.GetObj(i).XMLOutput(out,1);
137 
138  for(int i=0;i<gOptimizationObjRegistry.GetNb();i++)
139  gOptimizationObjRegistry.GetObj(i).XMLOutput(out,1);
140 
141  tag.SetIsEndTag(true);
142  out<<tag;
143  VFN_DEBUG_EXIT("XMLCrystFileSaveGlobal(ostream)",5)
144 }
145 
147 {
148  VFN_DEBUG_ENTRY("XMLCrystFileLoadObjectList(filename)",5)
149 
150  ifstream is(filename.c_str());
151  if(!is){};//:TODO:
152  is.imbue(std::locale::classic());
154  for(;;)
155  {
156  XMLCrystTag *pTag =new XMLCrystTag (is);
157  if(true==is.eof())
158  {
159  VFN_DEBUG_EXIT("XMLCrystFileLoadObjectList(filename):End",5)
160  for(int i=0;i<reg.GetNb();i++) reg.GetObj(i).Print();
161  is.close();
162  return reg;
163  }
164  //pTag->Print();
165  if(("Crystal"==pTag->GetName()||
166  "DiffractionDataSingleCrystal"==pTag->GetName()||
167  "PowderPattern"==pTag->GetName()||
168  "GlobalOptimObj"==pTag->GetName())
169  && !(pTag->IsEndTag())) reg.Register(*pTag);
170  else delete pTag;
171  }
172  return reg;
173 }
174 
175 template<class T> void XMLCrystFileLoadObject(const string & filename,
176  const string &tagName,
177  const string &name, T*obj)
178 {
179  VFN_DEBUG_ENTRY("XMLCrystFileLoadObject(filename,IOCrystTag,T&)",5)
180 
181  ifstream is(filename.c_str());
182  if(!is){};//:TODO:
183  is.imbue(std::locale::classic());
184  XMLCrystTag tag;
185  while(true)
186  {
187  is>>tag;
188  if(true==is.eof())
189  {
190  cout<<"XMLCrystFileLoadObject(filename,IOCrystTag,T&):Not Found !"<<endl;
191  is.close();
192  obj=0;
193  VFN_DEBUG_EXIT("XMLCrystFileLoadObject(filename,IOCrystTag,T&)",5)
194  return;
195  }
196  if(tagName!=tag.GetName())continue;
197  for(unsigned int i=0;i<tag.GetNbAttribute();i++)
198  if("Name"==tag.GetAttributeName(i))
199  if(name==tag.GetAttributeValue(i)) break;
200  }
201  VFN_DEBUG_MESSAGE("XMLCrystFileLoadObject(filename,IOCrystTag,T&):Found"<<tag,5)
202  obj = new T;
203  obj->XMLInput(is,tag);
204  is.close();
205  VFN_DEBUG_EXIT("XMLCrystFileLoadObject(filename,IOCrystTag,T&)",5)
206 }
207 
208 template void XMLCrystFileLoadObject(const string & ,const string &,const string &,
209  Crystal*);
210 template void XMLCrystFileLoadObject(const string & ,const string &,const string &,
211  PowderPattern*);
212 template void XMLCrystFileLoadObject(const string & ,const string &,const string &,
213  DiffractionDataSingleCrystal*);
214 //template void IOCrystFileLoadObject(const string &,const IOCrystTag &,
215 // ZScatterer*);
216 template void XMLCrystFileLoadObject(const string & ,const string &,const string &,
217  PowderPatternBackground*);
218 template void XMLCrystFileLoadObject(const string & ,const string &,const string &,
219  PowderPatternDiffraction*);
220 template void XMLCrystFileLoadObject(const string & ,const string &,const string &,
221  MonteCarloObj*);
222 
223 void XMLCrystFileLoadAllObject(const string & filename)
224 {
225  VFN_DEBUG_ENTRY("XMLCrystFileLoadAllObject(filename,)",5)
226  ifstream is(filename.c_str());
227  if(is.fail()) throw ObjCrystException("XMLCrystFileLoadAllObject() failed input");
229  (*fpObjCrystInformUser)("Finished loading XML file:"+filename);
230  VFN_DEBUG_EXIT("XMLCrystFileLoadAllObject(filename,)",5)
231 }
232 void XMLCrystFileLoadAllObject(istream &is)
233 {
234  VFN_DEBUG_ENTRY("XMLCrystFileLoadAllObject(istream)",5)
235  is.imbue(std::locale::classic());
236  XMLCrystTag tag;
237  do {is>>tag;} while(("ObjCryst"!=tag.GetName()) && (false==is.eof()));
238 
239  while(true)
240  {
241  XMLCrystTag tag(is);
242  if(true==is.eof()) break;
243  if(tag.GetName()=="Crystal")
244  {
245  Crystal* obj = new Crystal;
246  obj->XMLInput(is,tag);
247  }
248  if(tag.GetName()=="PowderPattern")
249  {
250  PowderPattern* obj = new PowderPattern;
251  obj->XMLInput(is,tag);
252  }
253  if(tag.GetName()=="DiffractionDataSingleCrystal")
254  {
255  DiffractionDataSingleCrystal* obj = new DiffractionDataSingleCrystal;
256  obj->XMLInput(is,tag);
257  }
258  if(tag.GetName()=="GlobalOptimObj")
259  {
260  MonteCarloObj* obj = new MonteCarloObj;
261  obj->XMLInput(is,tag);
262  }
263  }
264  (*fpObjCrystInformUser)("Finished loading XML");
265  VFN_DEBUG_EXIT("XMLCrystFileLoadAllObject(istream)",5)
266 }
268 //
269 // I/O ScatteringPowerAtom
270 //
272 void ScatteringPowerAtom::XMLOutput(ostream &os,int indent)const
273 {
274  VFN_DEBUG_ENTRY("ScatteringPowerAtom::XMLOutput():"<<this->GetName(),5)
275  for(int i=0;i<indent;i++) os << " " ;
276  XMLCrystTag tag("ScatteringPowerAtom");
277  tag.AddAttribute("Name",mName);
278  tag.AddAttribute("Symbol",mSymbol);
279  os <<tag<<endl;
280 
281  this->GetPar(&mBiso).XMLOutput(os,"Biso",indent+1);
282  os<<endl;
283  if(false==this->mIsIsotropic)
284  {
285  REAL* bdata = (REAL*) mB.data();
286  this->GetPar(&bdata[0]).XMLOutput(os,"B11",indent+1);
287  os<<endl;
288  this->GetPar(&bdata[1]).XMLOutput(os,"B22",indent+1);
289  os<<endl;
290  this->GetPar(&bdata[2]).XMLOutput(os,"B33",indent+1);
291  os<<endl;
292  this->GetPar(&bdata[3]).XMLOutput(os,"B12",indent+1);
293  os<<endl;
294  this->GetPar(&bdata[4]).XMLOutput(os,"B13",indent+1);
295  os<<endl;
296  this->GetPar(&bdata[5]).XMLOutput(os,"B23",indent+1);
297  os<<endl;
298  }
299 
300  this->GetPar("ML Error").XMLOutput(os,"ML Error",indent+1);
301  os <<endl;
302 
303  this->GetPar("ML-Nb Ghost Atoms").XMLOutput(os,"ML-NbGhost",indent+1);
304  os <<endl;
305 
306  this->GetPar("Formal Charge").XMLOutput(os,"Formal Charge",indent+1);
307  os <<endl;
308 
309  for(int i=0;i<=indent;i++) os << " " ;
310  XMLCrystTag tag2("RGBColour");
311  os << tag2
312  << mColourRGB[0]<<" "
313  << mColourRGB[1]<<" "
314  << mColourRGB[2];
315  tag2.SetIsEndTag(true);
316  os << tag2<<endl;
317 
318  tag.SetIsEndTag(true);
319  for(int i=0;i<indent;i++) os << " " ;
320  os <<tag<<endl;
321  VFN_DEBUG_EXIT("ScatteringPowerAtom::XMLOutput():"<<this->GetName(),5)
322 }
323 
324 void ScatteringPowerAtom::XMLInput(istream &is,const XMLCrystTag &tagg)
325 {
326  VFN_DEBUG_ENTRY("ScatteringPowerAtom::XMLInput():"<<this->GetName(),5)
327  for(unsigned int i=0;i<tagg.GetNbAttribute();i++)
328  {
329  if("Name"==tagg.GetAttributeName(i)) this->SetName(tagg.GetAttributeValue(i));
330  if("Symbol"==tagg.GetAttributeName(i)) mSymbol=tagg.GetAttributeValue(i);
331  }
332  (*fpObjCrystInformUser)("Input ScatteringPowerAtom:"+mName+"("+mSymbol+")");
333  this->Init(mName,mSymbol,mBiso);
334  while(true)
335  {
336  XMLCrystTag tag(is);
337  if(("ScatteringPowerAtom"==tag.GetName())&&tag.IsEndTag())
338  {
339  VFN_DEBUG_EXIT("ScatteringPowerAtom::Exit():"<<this->GetName(),5)
340  return;
341  }
342  if("RGBColour"==tag.GetName())
343  {
344  float r,g,b;
345  is>>r>>g>>b;
346  this->SetColour(r,g,b);
347  XMLCrystTag junk(is);
348  }
349  if("Par"==tag.GetName())
350  {
351  for(unsigned int i=0;i<tag.GetNbAttribute();i++)
352  {
353  if("Name"==tag.GetAttributeName(i))
354  {
355  if("Biso"==tag.GetAttributeValue(i))
356  {
357  this->GetPar(&mBiso).XMLInput(is,tag);
358  this->mIsIsotropic = true;
359  break;
360  }
361  if("B11"==tag.GetAttributeValue(i))
362  {
363  this->GetPar(&mB.data()[0]).XMLInput(is,tag);
364  this->mIsIsotropic = false;
365  break;
366  }
367  if("B22"==tag.GetAttributeValue(i))
368  {
369  this->GetPar(&mB.data()[1]).XMLInput(is,tag);
370  this->mIsIsotropic = false;
371  break;
372  }
373  if("B33"==tag.GetAttributeValue(i))
374  {
375  this->GetPar(&mB.data()[2]).XMLInput(is,tag);
376  this->mIsIsotropic = false;
377  break;
378  }
379  if("B12"==tag.GetAttributeValue(i))
380  {
381  this->GetPar(&mB.data()[3]).XMLInput(is,tag);
382  this->mIsIsotropic = false;
383  break;
384  }
385  if("B13"==tag.GetAttributeValue(i))
386  {
387  this->GetPar(&mB.data()[4]).XMLInput(is,tag);
388  this->mIsIsotropic = false;
389  break;
390  }
391  if("B23"==tag.GetAttributeValue(i))
392  {
393  this->GetPar(&mB.data()[5]).XMLInput(is,tag);
394  this->mIsIsotropic = false;
395  break;
396  }
397  if("ML Error"==tag.GetAttributeValue(i))
398  {
399  this->GetPar("ML Error").XMLInput(is,tag);
400  break;
401  }
402  if("ML-NbGhost"==tag.GetAttributeValue(i))
403  {
404  this->GetPar("ML-Nb Ghost Atoms").XMLInput(is,tag);
405  break;
406  }
407  if("Formal Charge"==tag.GetAttributeValue(i))
408  {
409  this->GetPar("Formal Charge").XMLInput(is,tag);
410  break;
411  }
412  }
413  }
414  continue;
415  }
416  }
417 }
419 //
420 // I/O Atom
421 //
423 void Atom::XMLOutput(ostream &os,int indent)const
424 {
425  VFN_DEBUG_ENTRY("Atom::XMLOutput():"<<this->GetName(),5)
426  for(int i=0;i<indent;i++) os << " " ;
427  XMLCrystTag tag("Atom");
428  tag.AddAttribute("Name",mName);
429  tag.AddAttribute("ScattPow",mpScattPowAtom->GetName());
430  os <<tag;
431  os <<endl;
432  indent++;
433 
434  this->GetPar(mXYZ.data()+0).XMLOutput(os,"x",indent);
435  os <<endl;
436 
437  this->GetPar(mXYZ.data()+1).XMLOutput(os,"y",indent);
438  os <<endl;
439 
440  this->GetPar(mXYZ.data()+2).XMLOutput(os,"z",indent);
441  os <<endl;
442 
443  this->GetPar(&mOccupancy).XMLOutput(os,"Occup",indent);
444  os <<endl;
445 
446  tag.SetIsEndTag(true);
447  indent--;
448  for(int i=0;i<indent;i++) os << " " ;
449  os <<tag<<endl;
450 
451  VFN_DEBUG_EXIT("Atom::XMLOutput():"<<this->GetName(),5)
452 }
453 
454 void Atom::XMLInput(istream &is,const XMLCrystTag &tagg)
455 {
456  VFN_DEBUG_ENTRY("Atom::XMLInput():"<<this->GetName(),5)
457  string scattPowName;
458  for(unsigned int i=0;i<tagg.GetNbAttribute();i++)
459  {
460  if("Name"==tagg.GetAttributeName(i)) this->SetName(tagg.GetAttributeValue(i));
461  if("ScattPow"==tagg.GetAttributeName(i)) scattPowName=tagg.GetAttributeValue(i);
462  }
463  (*fpObjCrystInformUser)("XML: Loading Atom:"+this->GetName());
464  const ScatteringPower* scattPow=
465  &(this->GetCrystal().GetScatteringPowerRegistry().GetObj(scattPowName));
466  VFN_DEBUG_MESSAGE("Found Scattering Power:"<< scattPowName<<" at "<<scattPow,4);
467  this->Init(0,0,0,mName,scattPow,1);
468  while(true)
469  {
470  XMLCrystTag tag(is);
471  if(("Atom"==tag.GetName())&&tag.IsEndTag())
472  {
473  VFN_DEBUG_EXIT("Atom::Exit():"<<this->GetName(),5)
474  return;
475  }
476  if("Par"==tag.GetName())
477  {
478  for(unsigned int i=0;i<tag.GetNbAttribute();i++)
479  {
480  if("Name"==tag.GetAttributeName(i))
481  {
482  if("x"==tag.GetAttributeValue(i))
483  {
484  this->GetPar(mXYZ.data()+0).XMLInput(is,tag);
485  break;
486  }
487  if("y"==tag.GetAttributeValue(i))
488  {
489  this->GetPar(mXYZ.data()+1).XMLInput(is,tag);
490  break;
491  }
492  if("z"==tag.GetAttributeValue(i))
493  {
494  this->GetPar(mXYZ.data()+2).XMLInput(is,tag);
495  break;
496  }
497  if("Occup"==tag.GetAttributeValue(i))
498  {
499  this->GetPar(&mOccupancy).XMLInput(is,tag);
500  break;
501  }
502  }
503  }
504  continue;
505  }
506  }
507 }
509 //
510 // I/O ZAtom
511 //
513 void ZAtom::XMLOutput(ostream &os,int indent)const
514 {
515  VFN_DEBUG_ENTRY("ZAtom::XMLOutput():"<<this->GetName(),5)
516  for(int i=0;i<indent;i++) os << " " ;
517  XMLCrystTag tag("ZAtom");
518  tag.AddAttribute("Name",mName);
519  if(0!=this->GetScatteringPower())//else it is a dummy atom
520  tag.AddAttribute("ScattPow",this->GetScatteringPower()->GetName());
521 
522  tag.AddAttribute("BondAtom",this->GetZScatterer()
523  .GetZAtomRegistry()
524  .GetObj(this->GetZBondAtom())
525  .GetName());
526  tag.AddAttribute("AngleAtom",this->GetZScatterer()
527  .GetZAtomRegistry()
528  .GetObj(this->GetZAngleAtom())
529  .GetName());
530  tag.AddAttribute("DihedAtom",this->GetZScatterer()
531  .GetZAtomRegistry()
532  .GetObj(this->GetZDihedralAngleAtom())
533  .GetName());
534  os <<tag<<endl;
535  indent++;
536 
537 
538  this->GetZScatterer().GetPar(&mBondLength).XMLOutput(os,"BondLength",indent);
539  os <<endl;
540 
541  this->GetZScatterer().GetPar(&mAngle).XMLOutput(os,"Angle",indent);
542  os <<endl;
543 
544  this->GetZScatterer().GetPar(&mDihed).XMLOutput(os,"DihedAng",indent);
545  os <<endl;
546 
547  this->GetZScatterer().GetPar(&mOccupancy).XMLOutput(os,"Occup",indent);
548  os <<endl;
549 
550  indent--;
551  tag.SetIsEndTag(true);
552  for(int i=0;i<indent;i++) os << " " ;
553  os <<tag<<endl;
554  VFN_DEBUG_EXIT("ZAtom::XMLOutput():"<<this->GetName(),5)
555 }
556 
557 void ZAtom::XMLInput(istream &is,const XMLCrystTag &tagg)
558 {
559  VFN_DEBUG_ENTRY("ZAtom::XMLInput():"<<this->GetName(),5)
560  for(unsigned int i=0;i<tagg.GetNbAttribute();i++)
561  {
562  if("Name"==tagg.GetAttributeName(i))
563  {
564  this->SetName(tagg.GetAttributeValue(i));
565  continue;
566  }
567  if("ScattPow"==tagg.GetAttributeName(i))
568  {
569  const ScatteringPower* scattPow=&(this->GetZScatterer()
570  .GetCrystal()
572  .GetObj(tagg.GetAttributeValue(i)));
573  this->SetScatteringPower(scattPow);
574  continue;
575  }
576  if("BondAtom"==tagg.GetAttributeName(i))
577  {
578  mAtomBond=this->GetZScatterer().GetZAtomRegistry().Find(tagg.GetAttributeValue(i));
579  continue;
580  }
581  if("AngleAtom"==tagg.GetAttributeName(i))
582  {
583  mAtomAngle=this->GetZScatterer().GetZAtomRegistry().Find(tagg.GetAttributeValue(i));
584  continue;
585  }
586  if("DihedAtom"==tagg.GetAttributeName(i))
587  {
588  mAtomDihed=this->GetZScatterer().GetZAtomRegistry().Find(tagg.GetAttributeValue(i));
589  continue;
590  }
591  }
592  while(true)
593  {
594  XMLCrystTag tag(is);
595  if(("ZAtom"==tag.GetName())&&tag.IsEndTag())
596  {
597  VFN_DEBUG_EXIT("ZAtom::Exit():"<<this->GetName(),5)
598  return;
599  }
600  if("Par"==tag.GetName())
601  {
602  for(unsigned int i=0;i<tag.GetNbAttribute();i++)
603  {
604  if("Name"==tag.GetAttributeName(i))
605  {
606  if("BondLength"==tag.GetAttributeValue(i))
607  {
608  this->GetZScatterer().GetPar(&mBondLength).XMLInput(is,tag);
609  break;
610  }
611  if("Angle"==tag.GetAttributeValue(i))
612  {
613  this->GetZScatterer().GetPar(&mAngle).XMLInput(is,tag);
614  break;
615  }
616  if("DihedAng"==tag.GetAttributeValue(i))
617  {
618  this->GetZScatterer().GetPar(&mDihed).XMLInput(is,tag);
619  break;
620  }
621  if("Occup"==tag.GetAttributeValue(i))
622  {
623  this->GetZScatterer().GetPar(&mOccupancy).XMLInput(is,tag);
624  break;
625  }
626  }
627  }
628  continue;
629  }
630  }
631 }
632 
634 //
635 // I/O ZScatterer
636 //
638 void ZScatterer::XMLOutput(ostream &os,int indent)const
639 {
640  VFN_DEBUG_ENTRY("ZScatterer::XMLOutput():"<<this->GetName(),5)
641  for(int i=0;i<indent;i++) os << " " ;
642  XMLCrystTag tag("ZScatterer");
643  tag.AddAttribute("Name",mName);
644  os <<tag<<endl;
645  indent++;
646 
647  this->GetPar(mXYZ.data()+0).XMLOutput(os,"x",indent);
648  os <<endl;
649 
650  this->GetPar(mXYZ.data()+1).XMLOutput(os,"y",indent);
651  os <<endl;
652 
653  this->GetPar(mXYZ.data()+2).XMLOutput(os,"z",indent);
654  os <<endl;
655 
656  this->GetPar(&mOccupancy).XMLOutput(os,"Occup",indent);
657  os <<endl;
658 
659  this->GetPar(&mPhi).XMLOutput(os,"Phi",indent);
660  os <<endl;
661 
662  this->GetPar(&mChi).XMLOutput(os,"Chi",indent);
663  os <<endl;
664 
665  this->GetPar(&mPsi).XMLOutput(os,"Psi",indent);
666  os <<endl;
667 
668  for(int i=0;i<mZAtomRegistry.GetNb();i++) mZAtomRegistry.GetObj(i).XMLOutput(os,indent);
669 
670  if(mZAtomRegistry.GetNb()>0)
671  {
672  for(int i=0;i<=indent;i++) os << " " ;
673  XMLCrystTag tag2("PivotAtom",false,true);
674  tag2.AddAttribute("Name",this->GetZAtomRegistry().GetObj(mCenterAtomIndex).GetName());
675  os <<tag2<<endl;
676  }
677 
678  indent--;
679  tag.SetIsEndTag(true);
680  for(int i=0;i<indent;i++) os << " " ;
681  os <<tag<<endl;
682  VFN_DEBUG_EXIT("ZScatterer::XMLOutput():"<<this->GetName(),5)
683 }
684 
685 void ZScatterer::XMLInput(istream &is,const XMLCrystTag &tagg)
686 {
687  VFN_DEBUG_ENTRY("ZScatterer::XMLInput():"<<this->GetName(),5)
688  for(unsigned int i=0;i<tagg.GetNbAttribute();i++)
689  {
690  if("Name"==tagg.GetAttributeName(i)) this->SetName(tagg.GetAttributeValue(i));
691  }
692  (*fpObjCrystInformUser)("XML: Loading ZScatterer:"+this->GetName());
693  while(true)
694  {
695  XMLCrystTag tag(is);
696  if(("ZScatterer"==tag.GetName())&&tag.IsEndTag())
697  {
698  VFN_DEBUG_EXIT("ZScatterer::Exit():"<<this->GetName(),5)
699  return;
700  }
701  if("Par"==tag.GetName())
702  {
703  for(unsigned int i=0;i<tag.GetNbAttribute();i++)
704  {
705  if("Name"==tag.GetAttributeName(i))
706  {
707  if("x"==tag.GetAttributeValue(i))
708  {
709  this->GetPar(mXYZ.data()+0).XMLInput(is,tag);
710  break;
711  }
712  if("y"==tag.GetAttributeValue(i))
713  {
714  this->GetPar(mXYZ.data()+1).XMLInput(is,tag);
715  break;
716  }
717  if("z"==tag.GetAttributeValue(i))
718  {
719  this->GetPar(mXYZ.data()+2).XMLInput(is,tag);
720  break;
721  }
722  if("Occup"==tag.GetAttributeValue(i))
723  {
724  this->GetPar(&mOccupancy).XMLInput(is,tag);
725  break;
726  }
727  if("Phi"==tag.GetAttributeValue(i))
728  {
729  this->GetPar(&mPhi).XMLInput(is,tag);
730  break;
731  }
732  if("Chi"==tag.GetAttributeValue(i))
733  {
734  this->GetPar(&mChi).XMLInput(is,tag);
735  break;
736  }
737  if("Psi"==tag.GetAttributeValue(i))
738  {
739  this->GetPar(&mPsi).XMLInput(is,tag);
740  break;
741  }
742  }
743  }
744  continue;
745  }
746  if("ZAtom"==tag.GetName())
747  {
748  //we must take care of possible dummy atoms
749  const ScatteringPower* scattPow=0;
750  for(unsigned int i=0;i<tag.GetNbAttribute();i++)
751  if("ScattPow"==tag.GetAttributeName(i))
752  scattPow=&(this->GetCrystal().GetScatteringPowerRegistry()
753  .GetObj(tag.GetAttributeValue(i)));
754  const long nb=mZAtomRegistry.GetNb();
755  this->AddAtom("",scattPow,0,0,0,0,0,1);
756  mZAtomRegistry.GetObj(nb).XMLInput(is,tag);
757  // Update the name of refinable parameters
758  {
759  char buf [20];
760  sprintf(buf,"%d-%d",(int)nb,(int)(mZAtomRegistry.GetObj(nb).GetZBondAtom()));
761  this->GetPar(&(mZAtomRegistry.GetObj(nb).mBondLength))
762  .SetName("Length"+(string)buf);
763 
764  sprintf(buf,"%d-%d-%d",(int)nb,(int)(mZAtomRegistry.GetObj(nb).GetZBondAtom()),
765  (int)(mZAtomRegistry.GetObj(nb).GetZAngleAtom()));
766  this->GetPar(&(mZAtomRegistry.GetObj(nb).mAngle))
767  .SetName("Angle"+(string)buf);
768 
769  sprintf(buf,"%d-%d-%d-%d",(int)nb,(int)(mZAtomRegistry.GetObj(nb).GetZBondAtom()),
770  (int)(mZAtomRegistry.GetObj(nb).GetZAngleAtom()),
771  (int)(mZAtomRegistry.GetObj(nb).GetZDihedralAngleAtom()));
772  this->GetPar(&(mZAtomRegistry.GetObj(nb).mDihed))
773  .SetName("Dihed"+(string)buf);
774  }
775  }
776  if("PivotAtom"==tag.GetName())
777  {
778  for(unsigned int i=0;i<tag.GetNbAttribute();i++)
779  if("Name"==tag.GetAttributeName(i))
780  {
781  mCenterAtomIndex=this->GetZAtomRegistry().Find(tag.GetAttributeValue(i));
782  }
783  }
784  }
785 }
787 //
788 // I/O Crystal
789 //
791 void Crystal::XMLOutput(ostream &os,int indent)const
792 {
793  VFN_DEBUG_ENTRY("Crystal::XMLOutput():"<<this->GetName(),5)
794 
795  for(int i=0;i<indent;i++) os << " " ;
796  XMLCrystTag tag("Crystal");
797  tag.AddAttribute("Name",mName);
798  tag.AddAttribute("SpaceGroup",this->GetSpaceGroup().GetName());
799  os <<tag<<endl;
800  indent++;
801 
802  // :TODO:
803  this->GetPar("a").XMLOutput(os,"a",indent);
804  os <<endl;
805 
806  this->GetPar("b").XMLOutput(os,"b",indent);
807  os <<endl;
808 
809  this->GetPar("c").XMLOutput(os,"c",indent);
810  os <<endl;
811 
812  this->GetPar("alpha").XMLOutput(os,"alpha",indent);
813  os <<endl;
814 
815  this->GetPar("beta").XMLOutput(os,"beta",indent);
816  os <<endl;
817 
818  this->GetPar("gamma").XMLOutput(os,"gamma",indent);
819  os <<endl;
820 
821  for(unsigned int i=0;i<this->GetNbOption();i++)
822  {
823  this->GetOption(i).XMLOutput(os,indent);
824  os <<endl<<endl;
825  }
826 
827  for(int i=0;i<mScatteringPowerRegistry.GetNb();i++)
828  mScatteringPowerRegistry.GetObj(i).XMLOutput(os,indent);
829  os <<endl;
830  for(int i=0;i<mScattererRegistry.GetNb();i++)
831  mScattererRegistry.GetObj(i).XMLOutput(os,indent);
832  os <<endl;
833 
834  if(mvBumpMergePar.size()>0)
835  {
836  VBumpMergePar::const_iterator pos;
837  for(pos=mvBumpMergePar.begin();pos!=mvBumpMergePar.end();pos++)
838  {
839  for(int k=0;k<=indent;k++) os << " " ;
840  XMLCrystTag tagBump("AntiBumpDistance");
841  tagBump.AddAttribute("ScattPow1",pos->first.first->GetName());
842  tagBump.AddAttribute("ScattPow2",pos->first.second->GetName());
843  {
844  stringstream ss;
845  ss << pos->second.mCanOverlap;
846  tagBump.AddAttribute("AllowMerge",ss.str());
847  }
848  os<<tagBump;
849  tagBump.SetIsEndTag(true);
850  os<<sqrt(pos->second.mDist2)<<tagBump<<endl;
851  }
852  for(int k=0;k<=indent;k++) os << " " ;
853  XMLCrystTag tag2("AntiBumpScale");
854  os << tag2<< mBumpMergeScale;
855  tag2.SetIsEndTag(true);
856  os << tag2<<endl;
857  }
858  if(mvBondValenceRo.size()>0)
859  {
860  map<pair<const ScatteringPower*,const ScatteringPower*>, REAL>::const_iterator pos;
861  for(pos=mvBondValenceRo.begin();pos!=mvBondValenceRo.end();pos++)
862  {
863  for(int k=0;k<=indent;k++) os << " " ;
864  XMLCrystTag tagBVRo("BondValenceRo");
865  tagBVRo.AddAttribute("ScattPow1",pos->first.first->GetName());
866  tagBVRo.AddAttribute("ScattPow2",pos->first.second->GetName());
867  os<<tagBVRo;
868  tagBVRo.SetIsEndTag(true);
869  os<<pos->second<<tagBVRo<<endl;
870  }
871  for(int k=0;k<=indent;k++) os << " " ;
872  XMLCrystTag tag2("BondValenceCostScale");
873  os << tag2<< mBondValenceCostScale;
874  tag2.SetIsEndTag(true);
875  os << tag2<<endl;
876  }
877 
878  indent--;
879  tag.SetIsEndTag(true);
880  for(int i=0;i<indent;i++) os << " " ;
881  os <<tag<<endl;
882  VFN_DEBUG_EXIT("Crystal::XMLOutput():"<<this->GetName(),5)
883 }
884 
885 void Crystal::XMLInput(istream &is,const XMLCrystTag &tagg)
886 {
887  VFN_DEBUG_ENTRY("Crystal::XMLInput():"<<this->GetName(),5)
888  (*fpObjCrystInformUser)("XML: Loading Crystal:");
889  //Remove Scatterers and Scattering Powers
890  for(long i=0;i<mScatteringPowerRegistry.GetNb();i++)
891  {
892  this->RemoveSubRefObj(mScatteringPowerRegistry.GetObj(i));
893  mScatteringPowerRegistry.GetObj(i).DeRegisterClient(*this);
894  }
895  mScatteringPowerRegistry.DeleteAll();
896  for(long i=0;i<mScattererRegistry.GetNb();i++)
897  {
898  this->RemoveSubRefObj(mScattererRegistry.GetObj(i));
899  mScattererRegistry.GetObj(i).DeRegisterClient(*this);
900  }
901  mScattererRegistry.DeleteAll();
902 
903  for(unsigned int i=0;i<tagg.GetNbAttribute();i++)
904  {
905  if("Name"==tagg.GetAttributeName(i)) this->SetName(tagg.GetAttributeValue(i));
906  if("SpaceGroup"==tagg.GetAttributeName(i))
907  this->Init(1,2,3,M_PI/2,M_PI/2,M_PI/2,tagg.GetAttributeValue(i),this->GetName());
908  }
909  (*fpObjCrystInformUser)("XML: Loading Crystal:"+this->GetName()+"(spg:"+this->GetSpaceGroup().GetName()+")");
910  while(true)
911  {
912  XMLCrystTag tag(is);
913  if(("Crystal"==tag.GetName())&&tag.IsEndTag())
914  {
915  this->UpdateDisplay();
916  VFN_DEBUG_EXIT("Crystal::Exit():"<<this->GetName(),5)
917  return;
918  }
919  if("Par"==tag.GetName())
920  {
921  for(unsigned int i=0;i<tag.GetNbAttribute();i++)
922  {
923  if("Name"==tag.GetAttributeName(i))
924  {
925  this->GetPar(tag.GetAttributeValue(i)).XMLInput(is,tag);
926  }
927  }
928  continue;
929  }
930  if("Option"==tag.GetName())
931  {
932  for(unsigned int i=0;i<tag.GetNbAttribute();i++)
933  if("Name"==tag.GetAttributeName(i))
934  mOptionRegistry.GetObj(tag.GetAttributeValue(i)).XMLInput(is,tag);
935  this->InitRefParList();// Fix the "used" tag of refinable par after options
936  continue;
937  }
938  if("AntiBumpDistance"==tag.GetName())
939  {
940  float dist;
941  bool useMerge=false;
942  bool allowMerge;
943  string scattPow1;
944  string scattPow2;
945  for(unsigned int i=0;i<tag.GetNbAttribute();i++)
946  {
947  if("AllowMerge"==tag.GetAttributeName(i))
948  {
949  stringstream ss(tag.GetAttributeValue(i));
950  ss >>allowMerge;
951  useMerge=true;
952  continue;
953  }
954  if("ScattPow1"==tag.GetAttributeName(i)) scattPow1=tag.GetAttributeValue(i);
955  if("ScattPow2"==tag.GetAttributeName(i)) scattPow2=tag.GetAttributeValue(i);
956  }
957  is>>dist;
958  XMLCrystTag junk(is);//end tag
959  if(useMerge)
960  this->SetBumpMergeDistance(mScatteringPowerRegistry.GetObj(scattPow1),
961  mScatteringPowerRegistry.GetObj(scattPow2),
962  dist,allowMerge);
963  else this->SetBumpMergeDistance(mScatteringPowerRegistry.GetObj(scattPow1),
964  mScatteringPowerRegistry.GetObj(scattPow2),
965  dist);
966  continue;
967  }
968  if("BondValenceRo"==tag.GetName())
969  {
970  float ro;
971  string scattPow1;
972  string scattPow2;
973  for(unsigned int i=0;i<tag.GetNbAttribute();i++)
974  {
975  if("ScattPow1"==tag.GetAttributeName(i)) scattPow1=tag.GetAttributeValue(i);
976  if("ScattPow2"==tag.GetAttributeName(i)) scattPow2=tag.GetAttributeValue(i);
977  }
978  is>>ro;
979  XMLCrystTag junk(is);//end tag
980  this->AddBondValenceRo(mScatteringPowerRegistry.GetObj(scattPow1),
981  mScatteringPowerRegistry.GetObj(scattPow2),ro);
982  continue;
983  }
984  if("AntiBumpScale"==tag.GetName())
985  {
986  is>>mBumpMergeScale;
987  XMLCrystTag junk(is);
988  }
989  if("BondValenceCostScale"==tag.GetName())
990  {
991  is>>mBondValenceCostScale;
992  XMLCrystTag junk(is);
993  }
994  if("Atom"==tag.GetName())
995  {
996  VFN_DEBUG_ENTRY("Crystal::XMLInput():reading an Atom",5)
997  Atom *at=new Atom;
998  at->SetCrystal(*this);
999  at->XMLInput(is,tag);
1000  this->AddScatterer(at);
1001  VFN_DEBUG_EXIT("Crystal::XMLInput():reading an Atom",5)
1002  continue;
1003  }
1004  if("ScatteringPowerAtom"==tag.GetName())
1005  {
1006  VFN_DEBUG_ENTRY("Crystal::XMLInput():reading a ScatteringPowerAtom",5)
1007  VFN_DEBUG_MESSAGE("Crystal::XMLInput():reading a ScatteringPowerAtom",5)
1009  sc->XMLInput(is,tag);
1010  this->AddScatteringPower(sc);
1011  VFN_DEBUG_EXIT("Crystal::XMLInput():reading a ScatteringPowerAtom",5)
1012  continue;
1013  }
1014  if("ScatteringPowerSphere"==tag.GetName())
1015  {
1016  VFN_DEBUG_ENTRY("Crystal::XMLInput():reading a ScatteringPowerSphere",5)
1017  VFN_DEBUG_MESSAGE("Crystal::XMLInput():reading a ScatteringPowerSphere",5)
1019  sc->XMLInput(is,tag);
1020  this->AddScatteringPower(sc);
1021  VFN_DEBUG_EXIT("Crystal::XMLInput():reading a ScatteringPowerSphere",5)
1022  continue;
1023  }
1024  if("ZScatterer"==tag.GetName())
1025  {
1026  VFN_DEBUG_ENTRY("Crystal::XMLInput():reading a ZScatterer",5)
1027  VFN_DEBUG_MESSAGE("Crystal::XMLInput():reading a ZScatterer",5)
1028  ZScatterer *z=new ZScatterer("",*this);
1029  z->XMLInput(is,tag);
1030  this->AddScatterer(z);
1031  VFN_DEBUG_EXIT("Crystal::XMLInput():reading a ZScatterer",5)
1032  continue;
1033  }
1034  if("Molecule"==tag.GetName())
1035  {
1036  VFN_DEBUG_ENTRY("Crystal::XMLInput():reading a Molecule",5)
1037  VFN_DEBUG_MESSAGE("Crystal::XMLInput():reading a Molecule",5)
1038  Molecule *z=new Molecule(*this,"");
1039  z->XMLInput(is,tag);
1040  this->AddScatterer(z);
1041  VFN_DEBUG_EXIT("Crystal::XMLInput():reading a Molecule",5)
1042  continue;
1043  }
1044  }
1045  (*fpObjCrystInformUser)("XML: Finished loading Crystal:"+this->GetName());
1046 }
1048 //
1049 // I/O Radiation
1050 //
1052 void Radiation::XMLOutput(ostream &os,int indent)const
1053 {
1054  VFN_DEBUG_ENTRY("Radiation::XMLOutput():"<<this->GetName(),5)
1055  XMLCrystTag tag("Radiation");
1056  if(WAVELENGTH_ALPHA12==this->GetWavelengthType())
1057  tag.AddAttribute("XRayTube",mXRayTubeName);
1058  for(int i=0;i<indent;i++) os << " " ;
1059  os <<tag<<endl;
1060  indent++;
1061 
1062  mRadiationType.XMLOutput(os,indent);
1063  os<<endl;
1064 
1065  mWavelengthType.XMLOutput(os,indent);
1066  os<<endl;
1067 
1068  for(int i=0;i<indent;i++) os << " " ;
1069  {
1070  XMLCrystTag tag2("LinearPolarRate");
1071  os << tag2<< mLinearPolarRate;
1072  tag2.SetIsEndTag(true);
1073  os << tag2<<endl;
1074  }
1075 
1076  if(WAVELENGTH_ALPHA12==this->GetWavelengthType())
1077  {
1078  for(int i=0;i<indent;i++) os << " " ;
1079  {
1080  XMLCrystTag tag2("XRayTubeDeltaLambda");
1081  os << tag2<< mXRayTubeDeltaLambda;
1082  tag2.SetIsEndTag(true);
1083  os << tag2<<endl;
1084  }
1085  for(int i=0;i<indent;i++) os << " " ;
1086  {
1087  XMLCrystTag tag2("XRayTubeAlpha2Alpha1Ratio");
1088  os << tag2<< mXRayTubeAlpha2Alpha1Ratio;
1089  tag2.SetIsEndTag(true);
1090  os << tag2<<endl;
1091  }
1092  }
1093 
1094  switch(this->GetWavelengthType())
1095  {
1096  case WAVELENGTH_MONOCHROMATIC: this->GetPar(mWavelength.data()).XMLOutput(os,indent);break;
1097  case WAVELENGTH_ALPHA12:
1098  {
1099  this->GetPar(mWavelength.data()).XMLOutput(os,"Wavelength",indent);
1100  break;
1101  }
1102  case WAVELENGTH_TOF:break;
1103  default: throw ObjCrystException("This radiation is not implemented !!");
1104  }
1105  os<<endl;
1106 
1107  indent--;
1108  tag.SetIsEndTag(true);
1109  for(int i=0;i<indent;i++) os << " " ;
1110  os <<tag;
1111 
1112  VFN_DEBUG_EXIT("Radiation::XMLOutput():"<<this->GetName(),5)
1113 }
1114 
1115 void Radiation::XMLInput(istream &is,const XMLCrystTag &tagg)
1116 {
1117  VFN_DEBUG_ENTRY("Radiation::XMLInput():"<<this->GetName(),5)
1118  string scattPowName;
1119  for(unsigned int i=0;i<tagg.GetNbAttribute();i++)
1120  {
1121  if("XRayTube"==tagg.GetAttributeName(i))
1122  if(tagg.GetAttributeValue(i)!="") // Something went wrong !
1123  this->SetWavelength(tagg.GetAttributeValue(i));
1124  }
1125 
1126  while(true)
1127  {
1128  XMLCrystTag tag(is);
1129  if(("Radiation"==tag.GetName())&&tag.IsEndTag())
1130  {
1131  VFN_DEBUG_EXIT("Radiation::Exit():"<<this->GetName(),5)
1132  return;
1133  }
1134  if("Option"==tag.GetName())
1135  {
1136  for(unsigned int i=0;i<tag.GetNbAttribute();i++)
1137  if("Name"==tag.GetAttributeName(i))
1138  {
1139  if("Radiation"==tag.GetAttributeValue(i)) mRadiationType.XMLInput(is,tag);
1140  if("Spectrum"==tag.GetAttributeValue(i)) mWavelengthType.XMLInput(is,tag);
1141  }
1142  }
1143  if("LinearPolarRate"==tag.GetName())
1144  {
1145  is>>mLinearPolarRate;
1146  XMLCrystTag junk(is);
1147  }
1148  if("XRayTubeDeltaLambda"==tag.GetName())
1149  {
1150  is>>mXRayTubeDeltaLambda;
1151  XMLCrystTag junk(is);
1152  }
1153  if("XRayTubeAlpha2Alpha1Ratio"==tag.GetName())
1154  {
1155  is>>mXRayTubeAlpha2Alpha1Ratio;
1156  XMLCrystTag junk(is);
1157  }
1158  if("Par"==tag.GetName())
1159  {
1160  for(unsigned int i=0;i<tag.GetNbAttribute();i++)
1161  {
1162  if("Name"==tag.GetAttributeName(i))
1163  {
1164  if("Wavelength"==tag.GetAttributeValue(i))
1165  {
1166  this->GetPar(mWavelength.data()).XMLInput(is,tag);
1167  break;
1168  }
1169  }
1170  }
1171  continue;
1172  }
1173  }
1174 }
1176 //
1177 // I/O DiffractionDataSingleCrystal
1178 //
1180 void DiffractionDataSingleCrystal::XMLOutput(ostream &os,int indent)const
1181 {
1182  VFN_DEBUG_ENTRY("DiffractionDataSingleCrystal::XMLOutput():"<<this->GetName(),5)
1183  for(int i=0;i<indent;i++) os << " " ;
1184  XMLCrystTag tag("DiffractionDataSingleCrystal");
1185  tag.AddAttribute("Name",mName);
1186  tag.AddAttribute("Crystal",this->GetCrystal().GetName());
1187  os <<tag<<endl;
1188  indent++;
1189 
1190  this->GetPar("Scale factor").XMLOutput(os,"Scale factor",indent);
1191  os <<endl;
1192 
1193  mRadiation.XMLOutput(os,indent);
1194  os <<endl;
1195 
1196  this->GetPar(&mGlobalBiso).XMLOutput(os,"globalBiso",indent);
1197  os <<endl;
1198 
1199  mGroupOption.XMLOutput(os,indent);
1200  os <<endl;
1201 
1202  for(int i=0;i<indent;i++) os << " " ;
1203  XMLCrystTag tag2("MaxSinThetaOvLambda");
1204  os << tag2<< mMaxSinThetaOvLambda;
1205  tag2.SetIsEndTag(true);
1206  os << tag2<<endl<<endl;
1207 
1208  if(mGroupOption.GetChoice()!=2)
1209  {
1210  XMLCrystTag tag3("HKLIobsSigmaWeightList");
1211  for(int i=0;i<indent;i++) os << " " ;
1212  os <<tag3<<endl;
1213 
1214  for(long j=0;j<this->GetNbRefl();j++)
1215  {
1216  for(int i=0;i<=indent;i++) os << " " ;
1217  os << mIntH(j) <<" "
1218  << mIntK(j) <<" "
1219  << mIntL(j) <<" "
1220  << mObsIntensity(j) <<" "
1221  << mObsSigma(j) <<" "
1222  << mWeight(j) <<" "
1223  <<endl;
1224  }
1225 
1226  tag3.SetIsEndTag(true);
1227  for(int i=0;i<indent;i++) os << " " ;
1228  os <<tag3<<endl;
1229  }
1230  else
1231  {
1232  XMLCrystTag tag3("HKLIobsSigmaWeightGROUPList");
1233  for(int i=0;i<indent;i++) os << " " ;
1234  os <<tag3<<endl;
1235 
1236  long first=0;
1237  for(long j=0;j<mNbGroup;j++)
1238  {
1239  XMLCrystTag tag4("HKLGroup");
1240  {
1241  stringstream s;
1242  s<<mGroupIobs(j);
1243  tag4.AddAttribute("Iobs",s.str());
1244  }
1245  {
1246  stringstream s;
1247  s<<mGroupSigma(j);
1248  tag4.AddAttribute("IobsSigma",s.str());
1249  }
1250  {
1251  stringstream s;
1252  s<<mGroupWeight(j);
1253  tag4.AddAttribute("Weight",s.str());
1254  }
1255  for(int i=0;i<=indent;i++) os << " " ;
1256  os<<tag4<<endl;
1257  for(long k=first;k<mGroupIndex(j);k++)
1258  {
1259  for(int i=0;i<=indent;i++) os << " " ;
1260  os << mIntH(k) <<" "<< mIntK(k) <<" "<< mIntL(k) <<" "<<endl;
1261  }
1262  for(int i=0;i<=indent;i++) os << " " ;
1263  tag4.SetIsEndTag(true);
1264  os<<tag4<<endl;
1265  first=mGroupIndex(j);
1266  }
1267 
1268  tag3.SetIsEndTag(true);
1269  for(int i=0;i<indent;i++) os << " " ;
1270  os <<tag3<<endl;
1271  }
1272 
1273  indent--;
1274  tag.SetIsEndTag(true);
1275  for(int i=0;i<indent;i++) os << " " ;
1276  os <<tag<<endl;
1277  VFN_DEBUG_EXIT("DiffractionDataSingleCrystal::XMLOutput():"<<this->GetName(),5)
1278 }
1279 
1281 {
1282  VFN_DEBUG_ENTRY("DiffractionDataSingleCrystal::XMLInput():"<<this->GetName(),5)
1283  for(unsigned int i=0;i<tagg.GetNbAttribute();i++)
1284  {
1285  if("Name"==tagg.GetAttributeName(i)) this->SetName(tagg.GetAttributeValue(i));
1286  if("Crystal"==tagg.GetAttributeName(i))
1287  this->SetCrystal(gCrystalRegistry.GetObj(tagg.GetAttributeValue(i)));
1288  }
1289  (*fpObjCrystInformUser)("XML: Loading Single Crystall data:"+this->GetName());
1290  while(true)
1291  {
1292  XMLCrystTag tag(is);
1293  if(("DiffractionDataSingleCrystal"==tag.GetName())&&tag.IsEndTag())
1294  {
1295  this->UpdateDisplay();
1296  VFN_DEBUG_EXIT("DiffractionDataSingleCrystal::XMLInput():"<<this->GetName(),5)
1297  return;
1298  }
1299  if("Option"==tag.GetName())
1300  {
1301  for(unsigned int i=0;i<tag.GetNbAttribute();i++)
1302  if("Name"==tag.GetAttributeName(i))
1303  {
1304  string name=tag.GetAttributeValue(i);
1305  if(name=="Twinning correction") name="Group Reflections";
1306  mOptionRegistry.GetObj(name).XMLInput(is,tag);
1307  }
1308  continue;
1309  }
1310  if("Par"==tag.GetName())
1311  {
1312  for(unsigned int i=0;i<tag.GetNbAttribute();i++)
1313  {
1314  if("Name"==tag.GetAttributeName(i))
1315  {
1316  if("Scale factor"==tag.GetAttributeValue(i))
1317  {
1318  this->GetPar(&mScaleFactor).XMLInput(is,tag);
1319  break;
1320  }
1321  }
1322  }
1323  }
1324  if("Radiation"==tag.GetName()) mRadiation.XMLInput(is,tag);
1325  if("MaxSinThetaOvLambda"==tag.GetName())
1326  {
1327  is>>mMaxSinThetaOvLambda;
1328  XMLCrystTag junk(is);
1329  }
1330  if("Par"==tag.GetName())
1331  {
1332  for(unsigned int i=0;i<tag.GetNbAttribute();i++)
1333  {
1334  if("Name"==tag.GetAttributeName(i))
1335  {
1336  if("globalBiso"==tag.GetAttributeValue(i))
1337  {
1338  this->GetPar(&mGlobalBiso).XMLInput(is,tag);
1339  break;
1340  }
1341  }
1342  }
1343  }
1344  if("HKLIobsSigmaWeightList"==tag.GetName())
1345  {
1346  long nbrefl=0;
1347  CrystVector_long h(100),k(100),l(100);
1348  CrystVector_REAL iobs(100),sigma(100),weight(100);
1349  do
1350  {
1351  is >>h(nbrefl)>>k(nbrefl)>>l(nbrefl);
1352  iobs (nbrefl)=InputFloat(is); if(ISNAN_OR_INF(iobs (nbrefl))||(iobs (nbrefl)<0)) iobs (nbrefl)=1e-8;
1353  sigma (nbrefl)=InputFloat(is); if(ISNAN_OR_INF(sigma (nbrefl))||(sigma (nbrefl)<0)) sigma (nbrefl)=1e-8;
1354  weight(nbrefl)=InputFloat(is); if(ISNAN_OR_INF(weight(nbrefl))||(weight(nbrefl)<0)) weight(nbrefl)=1e-8;
1355 
1356  nbrefl++;
1357  if(nbrefl==iobs.numElements())
1358  {
1359  h.resizeAndPreserve(nbrefl+100);
1360  k.resizeAndPreserve(nbrefl+100);
1361  l.resizeAndPreserve(nbrefl+100);
1362  iobs.resizeAndPreserve(nbrefl+100);
1363  sigma.resizeAndPreserve(nbrefl+100);
1364  weight.resizeAndPreserve(nbrefl+100);
1365  }
1366  while(0==isgraph(is.peek())) is.get();
1367  //cout << is.peek()<<" "<<nbrefl<<endl;
1368  }
1369  while(is.peek()!='<');//until next tag
1370  XMLCrystTag junkEndTag(is);
1371 
1372  h.resizeAndPreserve(nbrefl);
1373  k.resizeAndPreserve(nbrefl);
1374  l.resizeAndPreserve(nbrefl);
1375  iobs.resizeAndPreserve(nbrefl);
1376  sigma.resizeAndPreserve(nbrefl);
1377  weight.resizeAndPreserve(nbrefl);
1378  this->SetHklIobs(h,k,l,iobs,sigma);
1379  this->SetWeight(weight);
1380  this->SortReflectionBySinThetaOverLambda();
1381  this->CalcIcalc();
1382  this->FitScaleFactorForRw();
1383  }
1384  if("HKLIobsSigmaWeightGROUPList"==tag.GetName())
1385  {
1386  mNbRefl=0;
1387  mNbGroup=0;
1388  // This must NOT be changed with this kind of data.
1389  mGroupOption.SetChoice(2);
1390  // So de-register the option so that it is hidden from the user's view
1391  mOptionRegistry.DeRegister(mGroupOption);
1392  mClockMaster.RemoveChild(mGroupOption.GetClock());
1393  mH.resize(500);
1394  mK.resize(500);
1395  mL.resize(500);
1396  mObsIntensity.resize(500);
1397  mObsSigma.resize(500);
1398  mGroupIndex.resize(500);
1399  mGroupIobs.resize(500);
1400  mGroupSigma.resize(500);
1401  mGroupWeight.resize(500);
1402  while(true)
1403  {
1404  XMLCrystTag grouptag(is);
1405  if(grouptag.GetName()=="HKLIobsSigmaWeightGROUPList") break;
1406  if(grouptag.GetName()=="HKLGroup")
1407  {
1408  for(unsigned int i=0;i<grouptag.GetNbAttribute();++i)
1409  {
1410  if(grouptag.GetAttributeName(i)=="Iobs")
1411  {
1412  stringstream sst;
1413  sst<<grouptag.GetAttributeValue(i);
1414  sst>>mGroupIobs(mNbGroup);
1415  continue;
1416  }
1417  if(grouptag.GetAttributeName(i)=="IobsSigma")
1418  {
1419  stringstream sst;
1420  sst<<grouptag.GetAttributeValue(i);
1421  sst>>mGroupSigma(mNbGroup);
1422  continue;
1423  }
1424  if(grouptag.GetAttributeName(i)=="Weight")
1425  {
1426  stringstream sst;
1427  sst<<grouptag.GetAttributeValue(i);
1428  sst>>mGroupWeight(mNbGroup);
1429  continue;
1430  }
1431  }
1432  VFN_DEBUG_MESSAGE("Group #"<<mNbGroup<<" ,Iobs="<<mGroupIobs(mNbGroup)<<" ,Sigma="<<mGroupSigma(mNbGroup)<<" ,Weight="<<mGroupWeight(mNbGroup),2)
1433  do
1434  {
1435  is >>mH(mNbRefl)>>mK(mNbRefl)>>mL(mNbRefl);
1436  VFN_DEBUG_MESSAGE(" "<<mH(mNbRefl)<<" "<<mK(mNbRefl)<<" "<<mL(mNbRefl),2)
1437  mGroupIndex(mNbRefl)=mNbGroup;
1438  mNbRefl++;
1439  if(mNbRefl==mH.numElements())
1440  {
1441  mH.resizeAndPreserve(mNbRefl+500);
1442  mK.resizeAndPreserve(mNbRefl+500);
1443  mL.resizeAndPreserve(mNbRefl+500);
1444  mObsIntensity.resizeAndPreserve(mNbRefl+500);
1445  mObsSigma.resizeAndPreserve(mNbRefl+500);
1446  mGroupIndex.resizeAndPreserve(mNbRefl+500);
1447  }
1448  while(0==isgraph(is.peek())) is.get();
1449  }
1450  while(is.peek()!='<');//until end tag
1451  XMLCrystTag junkEndTag(is);
1452  if(++mNbGroup==mGroupIobs.numElements())
1453  {
1454  mGroupIobs.resizeAndPreserve(mNbGroup+500);
1455  mGroupSigma.resizeAndPreserve(mNbGroup+500);
1456  mGroupWeight.resizeAndPreserve(mNbGroup+500);
1457  }
1458  }
1459  }
1460  mH.resizeAndPreserve(mNbRefl);
1461  mK.resizeAndPreserve(mNbRefl);
1462  mL.resizeAndPreserve(mNbRefl);
1463  mObsIntensity.resizeAndPreserve(mNbRefl);
1464  mObsSigma.resizeAndPreserve(mNbRefl);
1465  mWeight.resizeAndPreserve(mNbRefl);
1466  mGroupIndex.resizeAndPreserve(mNbRefl);
1467 
1468  mGroupIobs.resizeAndPreserve(mNbGroup);
1469  mGroupWeight.resizeAndPreserve(mNbGroup);
1470  mGroupSigma.resizeAndPreserve(mNbGroup);
1471 
1472  mHasObservedData=true;
1473 
1474  mMultiplicity.resize(mNbRefl);
1475  mMultiplicity=1;
1476 
1477  this->PrepareHKLarrays();
1478  this->SortReflectionBySinThetaOverLambda();
1479  }
1480  }
1481  (*fpObjCrystInformUser)("XML: Finished loading Single Crystal Data:"+this->GetName());
1482 }
1484 //
1485 // I/O PowderPatternBackground
1486 //
1488 void PowderPatternBackground::XMLOutput(ostream &os,int indent)const
1489 {
1490  VFN_DEBUG_ENTRY("PowderPatternBackground::XMLOutput():"<<this->GetName(),5)
1491  for(int i=0;i<indent;i++) os << " " ;
1492  XMLCrystTag tag("PowderPatternBackground");
1493  tag.AddAttribute("Name",this->GetName());
1494  os <<tag<<endl;
1495  indent++;
1496 
1497  mInterpolationModel.XMLOutput(os,indent);
1498  os<<endl;
1499 
1500  XMLCrystTag tag2("XIntensityList");
1501  for(int i=0;i<indent;i++) os << " " ;
1502  os <<tag2<<endl;
1503 
1504  REAL scale=1.0;
1505  if(this->GetParentPowderPattern().GetRadiation().GetWavelengthType()!=WAVELENGTH_TOF)
1506  scale=RAD2DEG;
1507 
1508  for(long j=0;j<mBackgroundNbPoint;j++)
1509  {
1510 
1511  for(int i=0;i<=indent;i++) os << " " ;
1512  os << mBackgroundInterpPointX(j)*scale <<" "
1513  << mBackgroundInterpPointIntensity(j) <<" "
1514  << !this->GetPar(mBackgroundInterpPointIntensity.data()+j).IsFixed()<<" "
1515  <<endl;
1516  }
1517 
1518  tag2.SetIsEndTag(true);
1519  for(int i=0;i<indent;i++) os << " " ;
1520  os <<tag2<<endl;
1521 
1522  #ifdef USE_BACKGROUND_MAXLIKE_ERROR
1523  this->GetPar("ML Model Error").XMLOutput(os,"ML Model Error",indent);
1524  os <<endl;
1525  #endif
1526 
1527  indent--;
1528  tag.SetIsEndTag(true);
1529  for(int i=0;i<indent;i++) os << " " ;
1530  os <<tag<<endl;
1531  VFN_DEBUG_EXIT("PowderPatternBackground::XMLOutput():"<<this->GetName(),5)
1532 }
1533 
1534 void PowderPatternBackground::XMLInput(istream &is,const XMLCrystTag &tagg)
1535 {
1536  VFN_DEBUG_ENTRY("PowderPatternBackground::XMLInput():"<<this->GetName(),5)
1537  for(unsigned int i=0;i<tagg.GetNbAttribute();i++)
1538  {
1539  if("Name"==tagg.GetAttributeName(i)) this->SetName(tagg.GetAttributeValue(i));
1540  if("Interpolation"==tagg.GetAttributeName(i))
1541  {// Obsolete, but we must still read this
1542  if("Linear"==tagg.GetAttributeValue(i)) mInterpolationModel.SetChoice(0);
1543  if("Spline"==tagg.GetAttributeValue(i)) mInterpolationModel.SetChoice(1);
1544  }
1545  }
1546  while(true)
1547  {
1548  XMLCrystTag tag(is);
1549  if(("PowderPatternBackground"==tag.GetName())&&tag.IsEndTag())
1550  {
1551  this->UpdateDisplay();
1552  VFN_DEBUG_EXIT("PowderPatternBackground::Exit():"<<this->GetName(),5)
1553  return;
1554  }
1555  if(("TThetaIntensityList"==tag.GetName())||("XIntensityList"==tag.GetName()))
1556  {
1557  long nbPoint=0;
1558  CrystVector_REAL bckgd2Theta(100);
1559  CrystVector_REAL bckgd(100);
1560  CrystVector_bool fix(100);
1561  do
1562  {
1563  VFN_DEBUG_MESSAGE("PowderPatternBackground::XMLInput():"<<mBackgroundNbPoint,1)
1564  is >>bckgd2Theta(nbPoint)
1565  >>bckgd(nbPoint)
1566  >>fix(nbPoint);
1567  nbPoint++;
1568  if(nbPoint==bckgd2Theta.numElements())
1569  {
1570  bckgd2Theta.resizeAndPreserve(nbPoint+100);
1571  bckgd.resizeAndPreserve(nbPoint+100);
1572  fix.resizeAndPreserve(nbPoint+100);
1573  }
1574  while(0==isgraph(is.peek())) is.get();//Why do I need that ?
1575  //cout << is.peek()<<" "<<nbrefl<<endl;
1576  }
1577  while(is.peek()!='<');//until next tag
1578  bckgd2Theta.resizeAndPreserve(nbPoint);
1579  bckgd.resizeAndPreserve(nbPoint);
1580  if(this->GetParentPowderPattern().GetRadiation().GetWavelengthType()!=WAVELENGTH_TOF)
1581  bckgd2Theta*= DEG2RAD;
1582  this->SetInterpPoints(bckgd2Theta,bckgd);
1583  this->InitRefParList();
1584  //read closing tag
1585  XMLCrystTag junkEndTag(is);
1586  }
1587  if("Par"==tag.GetName())
1588  {
1589  for(unsigned int i=0;i<tag.GetNbAttribute();i++)
1590  {
1591  if("Name"==tag.GetAttributeName(i))
1592  {
1593  if("ML Model Error"==tag.GetAttributeValue(i))
1594  {
1595  #ifdef USE_BACKGROUND_MAXLIKE_ERROR
1596  this->GetPar("ML Model Error").XMLInput(is,tag);
1597  break;
1598  #endif
1599  }
1600  }
1601  }
1602  }
1603  if("Option"==tag.GetName())
1604  {
1605  for(unsigned int i=0;i<tag.GetNbAttribute();i++)
1606  if("Name"==tag.GetAttributeName(i))
1607  mOptionRegistry.GetObj(tag.GetAttributeValue(i)).XMLInput(is,tag);
1608  continue;
1609  }
1610  }
1611 }
1613 //
1614 // I/O PowderPatternDiffraction
1615 //
1617 void PowderPatternDiffraction::XMLOutput(ostream &os,int indent)const
1618 {
1619  VFN_DEBUG_ENTRY("PowderPatternDiffraction::XMLOutput():"<<this->GetName(),5)
1620  for(int i=0;i<indent;i++) os << " " ;
1621  XMLCrystTag tag("PowderPatternCrystal");
1622  tag.AddAttribute("Name",this->GetName());
1623  tag.AddAttribute("Crystal",this->GetCrystal().GetName());
1624  {
1625  stringstream ss;
1626  ss<<this->IsIgnoringImagScattFact();
1627  tag.AddAttribute("IgnoreImagScattFact",ss.str());
1628  }
1629  os <<tag<<endl;
1630  indent++;
1631 
1632  if(mFreezeLatticePar)
1633  {
1634  XMLCrystTag t("FrozenLatticePar");
1635  t.AddAttribute("a", (boost::format("%f")%mFrozenLatticePar(0)).str() );
1636  t.AddAttribute("b", (boost::format("%f")%mFrozenLatticePar(1)).str() );
1637  t.AddAttribute("c", (boost::format("%f")%mFrozenLatticePar(2)).str() );
1638  t.AddAttribute("alpha", (boost::format("%f")%(mFrozenLatticePar(3)*180/M_PI)).str() );
1639  t.AddAttribute("beta" , (boost::format("%f")%(mFrozenLatticePar(4)*180/M_PI)).str() );
1640  t.AddAttribute("gamma", (boost::format("%f")%(mFrozenLatticePar(5)*180/M_PI)).str() );
1641  t.SetIsEmptyTag(true);
1642  for(int i=0;i<indent;i++) os << " " ;
1643  os<<t<<endl;
1644  }
1645 
1646  if(mpReflectionProfile!=0) mpReflectionProfile->XMLOutput(os,indent);
1647 
1648  this->GetPar(&mGlobalBiso).XMLOutput(os,"globalBiso",indent);
1649  os <<endl;
1650 
1651  if(mCorrTextureMarchDollase.GetNbPhase()>0)
1652  {
1653  mCorrTextureMarchDollase.XMLOutput(os,indent);
1654  }
1655 
1656  mCorrTextureEllipsoid.XMLOutput(os,indent);
1657 
1658  #if 0
1659  if(mFhklObsSq.numElements()>0)
1660  {
1661  XMLCrystTag tag2("FhklObsSq");
1662  for(int i=0;i<indent;i++) os << " " ;
1663  os <<tag2<<endl;
1664 
1665  for(long j=0;j<this->GetNbRefl();j++)
1666  {
1667  for(int i=0;i<=indent;i++) os << " " ;
1668  os << mIntH(j) <<" "
1669  << mIntK(j) <<" "
1670  << mIntL(j) <<" "
1671  << mFhklObsSq(j) <<endl;
1672  }
1673 
1674  tag2.SetIsEndTag(true);
1675  for(int i=0;i<indent;i++) os << " " ;
1676  os <<tag2<<endl;
1677  }
1678  #else
1679  if(mpLeBailData!=0) mpLeBailData->XMLOutput(os,indent);
1680  #endif
1681 
1682  indent--;
1683  tag.SetIsEndTag(true);
1684  for(int i=0;i<indent;i++) os << " " ;
1685  os <<tag<<endl;
1686  VFN_DEBUG_EXIT("PowderPatternDiffraction::XMLOutput():"<<this->GetName(),5)
1687 }
1688 
1690 {
1691  VFN_DEBUG_ENTRY("PowderPatternDiffraction::XMLInput():"<<this->GetName(),5)
1692  for(unsigned int i=0;i<tagg.GetNbAttribute();i++)
1693  {
1694  if("Name"==tagg.GetAttributeName(i)) this->SetName(tagg.GetAttributeValue(i));
1695  if("Crystal"==tagg.GetAttributeName(i))
1696  this->SetCrystal(gCrystalRegistry.GetObj(tagg.GetAttributeValue(i)));
1697  if("NeedLorentzCorr"==tagg.GetAttributeName(i))
1698  {
1699  stringstream ss(tagg.GetAttributeValue(i));
1700  bool b;
1701  ss>>b;
1702  //mNeedLorentzCorr=b;
1703  //mClockLorentzPolarSlitCorrPar.Reset();
1704  }
1705  if("NeedPolarCorr"==tagg.GetAttributeName(i))
1706  {
1707  stringstream ss(tagg.GetAttributeValue(i));
1708  bool b;
1709  ss>>b;
1710  //mNeedPolarCorr=b;
1711  //mClockLorentzPolarSlitCorrPar.Reset();
1712  }
1713  if("Polar_AFactor"==tagg.GetAttributeName(i))
1714  {
1715  stringstream ss(tagg.GetAttributeValue(i));
1716  float b;
1717  ss>>b;
1718  //mPolarAfactor=b;
1719  //mClockLorentzPolarSlitCorrPar.Reset();
1720  }
1721  if("NeedSlitApertureCorr"==tagg.GetAttributeName(i))
1722  {
1723  stringstream ss(tagg.GetAttributeValue(i));
1724  bool b;
1725  ss>>b;
1726  //mNeedSlitApertureCorr=b;
1727  //mClockLorentzPolarSlitCorrPar.Reset();
1728  }
1729  if("IgnoreImagScattFact"==tagg.GetAttributeName(i))
1730  {
1731  stringstream ss(tagg.GetAttributeValue(i));
1732  bool b;
1733  ss>>b;
1734  this->SetIsIgnoringImagScattFact(b);
1735  mClockLorentzPolarSlitCorrPar.Reset();
1736  }
1737  }
1738  while(true)
1739  {
1740  XMLCrystTag tag(is);
1741  if(("PowderPatternCrystal"==tag.GetName())&&tag.IsEndTag())
1742  {
1743  this->UpdateDisplay();
1744  VFN_DEBUG_EXIT("PowderPatternDiffraction::Exit():"<<this->GetName(),5)
1745  return;
1746  }
1747  if("Par"==tag.GetName())
1748  {
1749  for(unsigned int i=0;i<tag.GetNbAttribute();i++)
1750  {
1751  if("Name"==tag.GetAttributeName(i))
1752  {
1753  if("globalBiso"==tag.GetAttributeValue(i))
1754  {
1755  this->GetPar(&mGlobalBiso).XMLInput(is,tag);
1756  break;
1757  }
1758  if("U"==tag.GetAttributeValue(i))
1759  {
1760  mpReflectionProfile->GetPar("U").XMLInput(is,tag);
1761  break;
1762  }
1763  if("V"==tag.GetAttributeValue(i))
1764  {
1765  mpReflectionProfile->GetPar("V").XMLInput(is,tag);
1766  break;
1767  }
1768  if("W"==tag.GetAttributeValue(i))
1769  {
1770  mpReflectionProfile->GetPar("W").XMLInput(is,tag);
1771  break;
1772  }
1773  if("Eta0"==tag.GetAttributeValue(i))
1774  {
1775  mpReflectionProfile->GetPar("Eta0").XMLInput(is,tag);
1776  break;
1777  }
1778  if("Eta1"==tag.GetAttributeValue(i))
1779  {
1780  mpReflectionProfile->GetPar("Eta1").XMLInput(is,tag);
1781  break;
1782  }
1783  if("W0"==tag.GetAttributeValue(i))
1784  {
1785  //:TODO: mpReflectionProfile->GetPar("Eta0").XMLInput(is,tag);
1786  break;
1787  }
1788  if("W1"==tag.GetAttributeValue(i))
1789  {
1790  //:TODO: mpReflectionProfile->GetPar("Eta1").XMLInput(is,tag);
1791  break;
1792  }
1793  if("W2"==tag.GetAttributeValue(i))
1794  {
1795  //:TODO: mpReflectionProfile->GetPar("Eta2").XMLInput(is,tag);
1796  break;
1797  }
1798  }
1799  }
1800  continue;
1801  }
1802  if("Option"==tag.GetName())
1803  {
1804  for(unsigned int i=0;i<tag.GetNbAttribute();i++)
1805  {
1806  if("Name"==tag.GetAttributeName(i))
1807  {
1808  if("Profile Type"!=tag.GetAttributeValue(i))
1809  mOptionRegistry.GetObj(tag.GetAttributeValue(i)).XMLInput(is,tag);
1810  }
1811  }
1812  continue;
1813  }
1814  if("TextureMarchDollase"==tag.GetName())
1815  {
1816  mCorrTextureMarchDollase.XMLInput(is,tag);
1817  continue;
1818  }
1819  if("TextureEllipsoid"==tag.GetName())
1820  {
1821  mCorrTextureEllipsoid.XMLInput(is,tag);
1822  continue;
1823  }
1824  if("ReflectionProfilePseudoVoigt"==tag.GetName())
1825  {
1826  if(mpReflectionProfile==0)
1827  {
1828  mpReflectionProfile=new ReflectionProfilePseudoVoigt;
1829  }
1830  else
1831  if(mpReflectionProfile->GetClassName()!="ReflectionProfilePseudoVoigt")
1832  {
1833  this->SetProfile(new ReflectionProfilePseudoVoigt);
1834  }
1835  mpReflectionProfile->XMLInput(is,tag);
1836  continue;
1837  }
1838  if("ReflectionProfilePseudoVoigtAnisotropic"==tag.GetName())
1839  {
1840  if(mpReflectionProfile==0)
1841  {
1842  mpReflectionProfile=new ReflectionProfilePseudoVoigtAnisotropic;
1843  }
1844  else
1845  if(mpReflectionProfile->GetClassName()!="ReflectionProfilePseudoVoigtAnisotropic")
1846  {
1847  this->SetProfile(new ReflectionProfilePseudoVoigtAnisotropic);
1848  }
1849  mpReflectionProfile->XMLInput(is,tag);
1850  continue;
1851  }
1852  if("ReflectionProfileDoubleExponentialPseudoVoigt"==tag.GetName())
1853  {
1854  if(mpReflectionProfile==0)
1855  {
1856  mpReflectionProfile
1857  =new ReflectionProfileDoubleExponentialPseudoVoigt(this->GetCrystal());
1858  }
1859  else
1860  if(mpReflectionProfile->GetClassName()!="ReflectionProfileDoubleExponentialPseudoVoigt")
1861  {
1862  this->SetProfile(new ReflectionProfileDoubleExponentialPseudoVoigt(this->GetCrystal()));
1863  }
1864  mpReflectionProfile->XMLInput(is,tag);
1865  continue;
1866  }
1867  if("FhklObsSq"==tag.GetName())
1868  {// old-style extracted data
1869  long nbrefl=0;
1870  CrystVector_REAL iobs(100),sigma;
1871  CrystVector_long h(100),k(100),l(100);
1872  mFhklObsSq.resize(100);
1873  do
1874  {
1875  is >>h(nbrefl)>>k(nbrefl)>>l(nbrefl)>>iobs(nbrefl);
1876  nbrefl++;
1877  if(nbrefl==h.numElements())
1878  {
1879  h.resizeAndPreserve(nbrefl+100);
1880  k.resizeAndPreserve(nbrefl+100);
1881  l.resizeAndPreserve(nbrefl+100);
1882  iobs.resizeAndPreserve(nbrefl+100);
1883  }
1884  while(0==isgraph(is.peek())) is.get();
1885  }
1886  while(is.peek()!='<');//until next tag
1887  XMLCrystTag junkEndTag(is);
1888  h.resizeAndPreserve(nbrefl);
1889  k.resizeAndPreserve(nbrefl);
1890  l.resizeAndPreserve(nbrefl);
1891  iobs.resizeAndPreserve(nbrefl);
1892  sigma.resizeAndPreserve(nbrefl);
1893  sigma=1;
1894 
1895  if(mpLeBailData==0) mpLeBailData=new DiffractionDataSingleCrystal(this->GetCrystal(),false);
1896 
1897  mpLeBailData->SetHklIobs(h,k,l,iobs,sigma);
1898  mpLeBailData->SetWavelength(this->GetRadiation().GetWavelength()(0));
1899  mpLeBailData->SetRadiationType(this->GetRadiation().GetRadiationType());
1900 
1901  // Estimate resolution
1902  const REAL min=iobs.max()*1e-6;
1903  unsigned long iresol=0;
1904  for(long i=0;i<nbrefl;++i) if(iobs(i)>min) iresol=i;
1905  char buf[200];
1906  sprintf(buf,"LeBail (d=%4.2fA?):",1/(2*abs(mpLeBailData->GetSinThetaOverLambda()(iresol))+1e-6));
1907  mpLeBailData->SetName(string(buf)+this->GetCrystal().GetName());
1908  //mpLeBailData->SetName(string("LeBail (resol=?):")+this->GetCrystal().GetName());
1909  }
1910  if("DiffractionDataSingleCrystal"==tag.GetName())
1911  {// Le Bail data
1912  if(mpLeBailData==0) mpLeBailData=new DiffractionDataSingleCrystal(this->GetCrystal(),false);
1913  mpLeBailData->XMLInput(is,tag);
1914  }
1915  if("FrozenLatticePar"==tag.GetName())
1916  {
1917  this->FreezeLatticePar(true);
1918  for(unsigned int i=0;i<tag.GetNbAttribute();i++)
1919  {
1920  if("a"==tag.GetAttributeName(i))
1921  {
1922  stringstream ss(tag.GetAttributeValue(i));
1923  //ss.imbue(std::locale::classic());
1924  float v;
1925  ss>>v;
1926  this->SetFrozenLatticePar(0,v);
1927  }
1928  if("b"==tag.GetAttributeName(i))
1929  {
1930  stringstream ss(tag.GetAttributeValue(i));
1931  //ss.imbue(std::locale::classic());
1932  float v;
1933  ss>>v;
1934  this->SetFrozenLatticePar(1,v);
1935  }
1936  if("c"==tag.GetAttributeName(i))
1937  {
1938  stringstream ss(tag.GetAttributeValue(i));
1939  //ss.imbue(std::locale::classic());
1940  float v;
1941  ss>>v;
1942  this->SetFrozenLatticePar(2,v);
1943  }
1944  if("alpha"==tag.GetAttributeName(i))
1945  {
1946  stringstream ss(tag.GetAttributeValue(i));
1947  //ss.imbue(std::locale::classic());
1948  float v;
1949  ss>>v;
1950  this->SetFrozenLatticePar(3,v*M_PI/180);
1951  }
1952  if("beta"==tag.GetAttributeName(i))
1953  {
1954  stringstream ss(tag.GetAttributeValue(i));
1955  //ss.imbue(std::locale::classic());
1956  float v;
1957  ss>>v;
1958  this->SetFrozenLatticePar(4,v*M_PI/180);
1959  }
1960  if("gamma"==tag.GetAttributeName(i))
1961  {
1962  stringstream ss(tag.GetAttributeValue(i));
1963  //ss.imbue(std::locale::classic());
1964  float v;
1965  ss>>v;
1966  this->SetFrozenLatticePar(5,v*M_PI/180);
1967  }
1968  }
1969  }
1970  }
1971 }
1973 //
1974 // I/O PowderPattern
1975 //
1977 void PowderPattern::XMLOutput(ostream &os,int indent)const
1978 {
1979  VFN_DEBUG_ENTRY("PowderPattern::XMLOutput():"<<this->GetName(),5)
1980  for(int i=0;i<indent;i++) os << " " ;
1981  XMLCrystTag tag("PowderPattern");
1982  tag.AddAttribute("Name",mName);
1983  os <<tag<<endl;
1984  indent++;
1985 
1986  this->GetPar(&mXZero).XMLOutput(os,"Zero",indent);
1987  os <<endl;
1988  if(this->GetRadiation().GetWavelengthType()==WAVELENGTH_TOF)
1989  {
1990  this->GetPar(&mDIFC).XMLOutput(os,"TOF-DIFC",indent);
1991  os <<endl;
1992 
1993  this->GetPar(&mDIFA).XMLOutput(os,"TOF-DIFA",indent);
1994  os <<endl;
1995  }
1996  else
1997  {
1998  this->GetPar(&m2ThetaDisplacement).XMLOutput(os,"2ThetaDisplacement",indent);
1999  os <<endl;
2000 
2001  this->GetPar(&m2ThetaTransparency).XMLOutput(os,"2ThetaTransparency",indent);
2002  os <<endl;
2003  }
2004 
2005  for(unsigned int i=0;i<this->GetNbOption();i++)
2006  {
2007  this->GetOption(i).XMLOutput(os,indent);
2008  os <<endl<<endl;
2009  }
2010 
2011  mRadiation.XMLOutput(os,indent);
2012  os <<endl;
2013  {
2014  for(int i=0;i<indent;i++) os << " " ;
2015  XMLCrystTag tag2("MaxSinThetaOvLambda");
2016  os << tag2<< mMaxSinThetaOvLambda;
2017  tag2.SetIsEndTag(true);
2018  os << tag2<<endl<<endl;
2019  }
2020 
2021  for(int j=0;j<mPowderPatternComponentRegistry.GetNb();j++)
2022  {
2023  mPowderPatternComponentRegistry.GetObj(j).XMLOutput(os,indent);
2024  XMLCrystTag tagg("PowderPatternComponent",false,true);
2025  {
2026  stringstream ss;
2027  ss<<mScaleFactor(j);
2028  tagg.AddAttribute("Scale",ss.str());
2029  }
2030  tagg.AddAttribute("Name",mPowderPatternComponentRegistry.GetObj(j).GetName());
2031  os<<endl;
2032  for(int i=0;i<indent;i++) os << " " ;
2033  os<<tagg<<endl<<endl;
2034  }
2035  XMLCrystTag tag2("XIobsSigmaWeightList");
2036  for(int i=0;i<indent;i++) os << " " ;
2037  os<<tag2<<endl;
2038 
2039  REAL scale=1.0;
2040  if(this->GetRadiation().GetWavelengthType()!=WAVELENGTH_TOF)
2041  scale=RAD2DEG;
2042 
2043  for(unsigned long j=0;j<this->GetNbPoint();j++)
2044  {
2045  for(int i=0;i<=indent;i++) os << " " ;
2046  os << scale*mX(j) <<" "
2047  << mPowderPatternObs(j) <<" "
2048  << mPowderPatternObsSigma(j) <<" "
2049  << mPowderPatternWeight(j) <<" "
2050  <<endl;
2051  }
2052  tag2.SetIsEndTag(true);
2053  for(int i=0;i<indent;i++) os << " " ;
2054  os<<tag2<<endl;
2055 
2056  for(int j=0;j<mExcludedRegionMinX.numElements();j++)
2057  {
2058  XMLCrystTag tag3("ExcludeX");
2059  for(int i=0;i<indent;i++) os << " " ;
2060  if(this->GetRadiation().GetWavelengthType()==WAVELENGTH_TOF)
2061  {
2062  os << tag3
2063  << mExcludedRegionMinX(j) <<" "
2064  << mExcludedRegionMaxX(j) ;
2065  }
2066  else
2067  {
2068  os << tag3
2069  << mExcludedRegionMinX(j)*RAD2DEG <<" "
2070  << mExcludedRegionMaxX(j)*RAD2DEG ;
2071  }
2072  tag3.SetIsEndTag(true);
2073  os<<tag3<<endl;
2074  }
2075 
2076 
2077  indent--;
2078  tag.SetIsEndTag(true);
2079  for(int i=0;i<indent;i++) os << " " ;
2080  os <<tag<<endl;
2081  VFN_DEBUG_EXIT("PowderPattern::XMLOutput():"<<this->GetName(),5)
2082 }
2083 
2084 void PowderPattern::XMLInput(istream &is,const XMLCrystTag &tagg)
2085 {
2086  VFN_DEBUG_ENTRY("PowderPattern::XMLInput():"<<this->GetName(),5)
2087  for(unsigned int i=0;i<tagg.GetNbAttribute();i++)
2088  {
2089  if("Name"==tagg.GetAttributeName(i)) this->SetName(tagg.GetAttributeValue(i));
2090  }
2091  (*fpObjCrystInformUser)("XML: Loading Powder Pattern:"+this->GetName());
2092  while(true)
2093  {
2094  XMLCrystTag tag(is);
2095  if(("PowderPattern"==tag.GetName())&&tag.IsEndTag())
2096  {
2097  this->UpdateDisplay();
2098  VFN_DEBUG_EXIT("PowderPattern::Exit():"<<this->GetName(),5)
2099  return;
2100  }
2101  if("Radiation"==tag.GetName()) mRadiation.XMLInput(is,tag);
2102  if("MaxSinThetaOvLambda"==tag.GetName())
2103  {
2104  is>>mMaxSinThetaOvLambda;
2105  XMLCrystTag junk(is);
2106  }
2107  if("Par"==tag.GetName())
2108  {
2109  for(unsigned int i=0;i<tag.GetNbAttribute();i++)
2110  {
2111  if("Name"==tag.GetAttributeName(i))
2112  {
2113  if(("2ThetaZero"==tag.GetAttributeValue(i)) ||("Zero"==tag.GetAttributeValue(i)))
2114  {
2115  this->GetPar(&mXZero).XMLInput(is,tag);
2116  break;
2117  }
2118  if("2ThetaDisplacement"==tag.GetAttributeValue(i))
2119  {
2120  this->GetPar(&m2ThetaDisplacement).XMLInput(is,tag);
2121  break;
2122  }
2123  if("2ThetaTransparency"==tag.GetAttributeValue(i))
2124  {
2125  this->GetPar(&m2ThetaTransparency).XMLInput(is,tag);
2126  break;
2127  }
2128  if("TOF-DIFC"==tag.GetAttributeValue(i))
2129  {
2130  this->GetPar(&mDIFC).XMLInput(is,tag);
2131  break;
2132  }
2133  if("TOF-DIFA"==tag.GetAttributeValue(i))
2134  {
2135  this->GetPar(&mDIFA).XMLInput(is,tag);
2136  break;
2137  }
2138  }
2139  }
2140  continue;
2141  }
2142  if("Option"==tag.GetName())
2143  {
2144  for(unsigned int i=0;i<tag.GetNbAttribute();i++)
2145  if("Name"==tag.GetAttributeName(i))
2146  mOptionRegistry.GetObj(tag.GetAttributeValue(i)).XMLInput(is,tag);
2147  continue;
2148  }
2149  if("PowderPatternBackground"==tag.GetName())
2150  {
2152  comp->SetParentPowderPattern(*this);
2153  comp->XMLInput(is,tag);
2154  continue;
2155  }
2156  if("PowderPatternCrystal"==tag.GetName())
2157  {
2159  comp->SetParentPowderPattern(*this);
2160  comp->XMLInput(is,tag);
2161  continue;
2162  }
2163  if("PowderPatternComponent"==tag.GetName())
2164  {
2165  REAL scale=1.0;
2166  string name;
2167  for(unsigned int i=0;i<tag.GetNbAttribute();i++)
2168  {
2169  if("Scale"==tag.GetAttributeName(i))
2170  {
2171  stringstream ss(tag.GetAttributeValue(i));
2172  ss>>scale;
2173  continue;
2174  }
2175  if("Name"==tag.GetAttributeName(i)) name=tag.GetAttributeValue(i);
2176  }
2177  this->AddPowderPatternComponent(gPowderPatternComponentRegistry.GetObj(name));
2178  mScaleFactor(mPowderPatternComponentRegistry.GetNb()-1)=scale;
2179  VFN_DEBUG_MESSAGE("->Adding Component :"<<name<<"with scale="<<scale,8);
2180  continue;
2181  }
2182  if("ExcludeX"==tag.GetName())
2183  {
2184  float min,max;
2185  is>>min>>max;
2186  if(this->GetRadiation().GetWavelengthType()==WAVELENGTH_TOF)
2187  this->AddExcludedRegion(min,max);
2188  else this->AddExcludedRegion(min*DEG2RAD,max*DEG2RAD);
2189  XMLCrystTag end(is);
2190  continue;
2191  }
2192  if("IobsSigmaWeightList"==tag.GetName())
2193  {
2194  // Old version, just for 2theta-intensity pattern (no TOF)
2195  VFN_DEBUG_ENTRY("Loading Iobs-Sigma-Weight List...",8);
2196  REAL min,step;
2197  for(unsigned int i=0;i<tag.GetNbAttribute();i++)
2198  {
2199  if("TThetaMin"==tag.GetAttributeName(i))
2200  {
2201  stringstream ss(tag.GetAttributeValue(i));
2202  ss>>min;
2203  VFN_DEBUG_MESSAGE("2Theta min="<<min,8);
2204  min*=DEG2RAD;
2205  }
2206  if("TThetaStep"==tag.GetAttributeName(i))
2207  {
2208  stringstream ss(tag.GetAttributeValue(i));
2209  ss>>step;
2210  VFN_DEBUG_MESSAGE("2Theta step="<<step<<tag.GetAttributeValue(i),8);
2211  step*=DEG2RAD;
2212  }
2213  }
2214  while(0==isgraph(is.peek())) is.get();
2215  if(is.peek()=='<')
2216  {
2217  cout <<"PowderPattern::XMLInput(): no data point in the powder pattern !"<<endl;
2218  XMLCrystTag junk(is);
2219  VFN_DEBUG_EXIT("Loading Iobs-Sigma-Weight List...",8);
2220  continue;
2221  }
2222  mNbPoint=0;
2223  mPowderPatternObs.resize(500);
2224  mPowderPatternObsSigma.resize(500);
2225  mPowderPatternWeight.resize(500);
2226  do
2227  {
2228  is >>mPowderPatternObs(mNbPoint)
2229  >>mPowderPatternObsSigma(mNbPoint)
2230  >>mPowderPatternWeight(mNbPoint);
2231  mNbPoint++;
2232  VFN_DEBUG_MESSAGE("Point #"<<mNbPoint,5);
2233  if(mNbPoint==(unsigned long)mPowderPatternObs.numElements())
2234  {
2235  mPowderPatternObs.resizeAndPreserve(mNbPoint+500);
2236  mPowderPatternObsSigma.resizeAndPreserve(mNbPoint+500);
2237  mPowderPatternWeight.resizeAndPreserve(mNbPoint+500);
2238  }
2239  while(0==isgraph(is.peek())) is.get();
2240  }
2241  while(is.peek()!='<');//until next tag
2242  this->SetPowderPatternPar(min,step,mNbPoint);
2243  mClockPowderPatternPar.Click();
2244 
2245  XMLCrystTag junk(is);
2246  VFN_DEBUG_EXIT("Loading Iobs-Sigma-Weight List...",8);
2247  continue;
2248  }
2249  if("XIobsSigmaWeightList"==tag.GetName())
2250  {
2251  VFN_DEBUG_ENTRY("Loading X-Iobs-Sigma-Weight List...",8);
2252  while(0==isgraph(is.peek())) is.get();
2253  if(is.peek()=='<')
2254  {
2255  cout <<"PowderPattern::XMLInput(): no data point in the powder pattern !"<<endl;
2256  XMLCrystTag junk(is);
2257  VFN_DEBUG_EXIT("Loading Iobs-Sigma-Weight List...",8);
2258  continue;
2259  }
2260  mNbPoint=0;
2261  mX.resize(500);
2262  mPowderPatternObs.resize(500);
2263  mPowderPatternObsSigma.resize(500);
2264  mPowderPatternWeight.resize(500);
2265  do
2266  {
2267  is >>mX(mNbPoint)
2268  >>mPowderPatternObs(mNbPoint)
2269  >>mPowderPatternObsSigma(mNbPoint)
2270  >>mPowderPatternWeight(mNbPoint);
2271  mNbPoint++;
2272  VFN_DEBUG_MESSAGE("Point #"<<mNbPoint,5);
2273  if(mNbPoint==(unsigned long)mPowderPatternObs.numElements())
2274  {
2275  mX.resizeAndPreserve(mNbPoint+500);
2276  mPowderPatternObs.resizeAndPreserve(mNbPoint+500);
2277  mPowderPatternObsSigma.resizeAndPreserve(mNbPoint+500);
2278  mPowderPatternWeight.resizeAndPreserve(mNbPoint+500);
2279  }
2280  while(0==isgraph(is.peek())) is.get();
2281  }
2282  while(is.peek()!='<');//until next tag
2283  mX.resizeAndPreserve(mNbPoint);
2284  if(this->GetRadiation().GetWavelengthType()!=WAVELENGTH_TOF)
2285  mX*=DEG2RAD;
2286  this->SetPowderPatternX(mX);
2287 
2288  XMLCrystTag junk(is);
2289  VFN_DEBUG_EXIT("Loading X-Iobs-Sigma-Weight List...",8);
2290  continue;
2291  }
2292  }
2293 }
2294 } //namespace
T & GetObj(const unsigned int i)
Get object #i in the registry.
void Init(const REAL x, const REAL y, const REAL z, const string &name, const ScatteringPower *pow, const REAL popu=1)
initialize the atom (used for arrays of atoms).
Definition: Atom.cpp:129
void SetScatteringPower(const ScatteringPower *)
Set the ScatteringPower.
Definition: ZScatterer.cpp:108
virtual void XMLInput(istream &is, const XMLCrystTag &tag)
Input From stream.
Pseudo-Voigt reflection profile, with 6-parameters anisotropic Lorentzian broadening and Toraya asymm...
void SetColour(const string &colorName)
Set the colour from the associated POV-Ray name.
Double-Exponential Pseudo-Voigt profile for TOF.
float string2floatC(const string &s)
Function to convert a substring to a floating point value, imposing a C locale (using '...
Definition: ObjCryst/IO.cpp:59
long GetNb() const
Get the index of an object in the registry, from its name Warning: it can change if an object is remo...
virtual void XMLInput(istream &is, const XMLCrystTag &tag)
Input From stream.
void Register(T &obj)
Register a new object. Already registered objects are skipped.
virtual void SetParentPowderPattern(PowderPattern &)
Set the PowderPattern object which uses this component.
CrystVector_REAL mXYZ
coordinates of the scatterer (or of its center..)
Definition: Scatterer.h:273
virtual void XMLOutput(ostream &os, int indent=0) const
Output to stream in well-formed XML.
bool ISNAN_OR_INF(REAL r)
Test if the value is a NaN.
Definition: ObjCryst/IO.cpp:97
virtual void XMLInput(istream &is, const XMLCrystTag &tag)
Input From stream.
virtual void XMLOutput(ostream &os, int indent=0) const
Output to stream in well-formed XML.
ObjRegistry< OptimizationObj > gOptimizationObjRegistry("List of all Optimization objects")
Global Registry for all OptimizationObj.
virtual void XMLInput(istream &is, const XMLCrystTag &tag)
Input From stream.
Phase to compute a background contribution to a powder pattern using an interpolation.
virtual void XMLInput(istream &is, const XMLCrystTag &tag)
Input From stream.
void XMLInput(istream &is, const XMLCrystTag &tag)
XMLInput From stream.
RefinablePar & GetPar(const long i)
Access all parameters in the order they were inputted.
Class to compute the contribution to a powder pattern from a crystalline phase.
void XMLCrystFileLoadObject(const string &filename, const string &tagName, const string &name, T *obj)
Load an object from a file, identifying it from its tag.
virtual void XMLOutput(ostream &os, int indent=0) const
Output to stream in well-formed XML.
long GetZBondAtom() const
Index of the 1st atom used to define the atom in the Z-Matrix (the one from which the bondlength is c...
Definition: ZScatterer.cpp:95
long GetZDihedralAngleAtom() const
Index of the 3rd atom used to define the atom in the Z-Matrix (the one from which the dihedral angle ...
Definition: ZScatterer.cpp:97
bool mIsIsotropic
Is the scattering isotropic ?
virtual void SetParentPowderPattern(PowderPattern &)
Set the PowderPattern object which uses this component.
ObjRegistry< PowderPatternComponent > gPowderPatternComponentRegistry("List of all PowderPattern Components")
Global registry for all PowderPatternComponent objects.
ObjRegistry< Crystal > gCrystalRegistry("List of all Crystals")
Global registry for all Crystal objects.
Definition: Crystal.h:525
REAL mBiso
Temperature isotropic B factor.
\ brief ScatteringPower for a spherical particule
ObjRegistry< DiffractionDataSingleCrystal > gDiffractionDataSingleCrystalRegistry("Global DiffractionDataSingleCrystal Registry")
Global registry for all PowderPattern objects.
float InputFloat(istream &is, const char endchar)
Safely read a floating-point value from a stream.
Definition: ObjCryst/IO.cpp:68
string mName
Name for this RefinableObject. Should be unique, at least in the same scope.+.
const ZScatterer & GetZScatterer() const
Get the ZScatterer associated to this ZAtom.
Definition: ZScatterer.cpp:92
The basic atom scatterer, in a crystal.
Definition: Atom.h:57
virtual void XMLOutput(ostream &os, int indent=0) const
Output to stream in well-formed XML.
string mName
Name for this atom.
Definition: ZScatterer.h:145
void XMLCrystFileSaveGlobal(const string &filename)
Save all Objcryst++ objects.
CrystVector_REAL mB
Anisotropic B(ij)
virtual void XMLInput(istream &is, const XMLCrystTag &tag)
Input From stream.
Molecule : class for complex scatterer descriptions using cartesian coordinates with bond length/angl...
Definition: Molecule.h:731
Class for individual atoms in a ZScatterer Object.
Definition: ZScatterer.h:86
const ScatteringPower * mpScattPowAtom
The ScatteringPowerAtom associated to that atom.
Definition: Atom.h:157
virtual void XMLInput(istream &is, const XMLCrystTag &tag)
Input From stream.
long mAtomBond
The index (in the ZScatterer) of the atoms which are used to define the position of this atom...
Definition: ZScatterer.h:141
DiffractionData object for Single Crystal analysis.
virtual void XMLOutput(ostream &os, int indent=0) const
Output to stream in well-formed XML.
virtual void XMLInput(istream &is, const XMLCrystTag &tag)
Input From stream.
Definition: Molecule.cpp:2267
void XMLCrystFileLoadAllObject(const string &filename)
Load all 'top' objects from a file (Crystal, PowderPattern, DiffDataSingleCrystal and GlobalOptimObj ...
REAL mOccupancy
Occupancy : 0 <= occ <= 1 For a multi-atom scatterer (polyhedron,..), this is the overall occupancy o...
Definition: Scatterer.h:279
long GetZAngleAtom() const
Index of the 2nd atom used to define the atom in the Z-Matrix (the one from which the angle is calcul...
Definition: ZScatterer.cpp:96
string mSymbol
Symbol of this atom.
void Init()
Initialization of the object, used by all constructors, and operator=.
ObjRegistry< ScatteringPower > & GetScatteringPowerRegistry()
Get the registry of ScatteringPower included in this Crystal.
Definition: Crystal.cpp:222
ObjRegistry< XMLCrystTag > XMLCrystFileLoadObjectList(const string &filename)
Get the list (tags) of ObjCryst objects in a file.
float mColourRGB[3]
Colour for this ScatteringPower using RGB.
void SetCrystal(Crystal &)
Set the crystal in which is included this Scatterer.
Definition: Scatterer.cpp:136
ZScatterer: the basic type of complex scatterers, where atom positions are defined using a standard "...
Definition: ZScatterer.h:190
const Crystal & GetCrystal() const
In which crystal is this Scatterer included ?
Definition: Scatterer.cpp:137
virtual void XMLInput(istream &is, const XMLCrystTag &tag)
Input From stream.
Exception class for ObjCryst++ library.
Definition: General.h:119
The namespace which includes all objects (crystallographic and algorithmic) in ObjCryst++.
Definition: Atom.cpp:47
The Scattering Power for an Atom.
virtual const string & GetName() const
Name of the object.
REAL mBondLength
Bond length, angle and dihedral angle.
Definition: ZScatterer.h:143
virtual void XMLOutput(ostream &os, int indent=0) const
Output to stream in well-formed XML.
Pseudo-Voigt reflection profile.
virtual void XMLOutput(ostream &os, int indent=0) const
Output to stream in well-formed XML.
virtual void XMLOutput(ostream &os, int indent=0) const
Output to stream in well-formed XML.
class to input or output a well-formatted xml beginning or ending tag.
virtual void XMLInput(istream &is, const XMLCrystTag &tag)
Input From stream.
const ObjRegistry< ZAtom > & GetZAtomRegistry() const
Access to the registry of ZAtoms.
Definition: ZScatterer.cpp:466
virtual void XMLOutput(ostream &os, int indent=0) const
Output to stream in well-formed XML.
virtual void XMLInput(istream &is, const XMLCrystTag &tag)
Input From stream.
Object Registry.
Definition: RefinableObj.h:643
const ScatteringPower * GetScatteringPower() const
ScatteringPower for this atom.
Definition: ZScatterer.cpp:102
virtual void SetName(const string &name)
Name of the object.
void XMLOutput(ostream &os, const string &name, int indent=0) const
XMLOutput to stream in well-formed XML.
Abstract Base Class to describe the scattering power of any Scatterer component in a crystal...