Skip to content

Commit e7284e0

Browse files
authored
Merge pull request #9 from vincefn/master
Update from upstream
2 parents c6658f3 + 27d0c39 commit e7284e0

17 files changed

Lines changed: 690 additions & 36 deletions

src/ObjCryst/ObjCryst/Atom.cpp

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -169,16 +169,23 @@ string Atom::GetComponentName(const int i) const{ return this->GetName();}
169169
void Atom::Print() const
170170
{
171171
VFN_DEBUG_MESSAGE("Atom::Print()",1)
172-
cout << "Atom ("
173-
<< FormatString(mpScattPowAtom->GetSymbol(),4) << ") :"
174-
<< FormatString(this->GetName(),16) << " at : "
175-
<< FormatFloat(this->GetX())
176-
<< FormatFloat(this->GetY())
177-
<< FormatFloat(this->GetZ());
178-
if(this->IsDummy()) cout << " DUMMY! ";
172+
if(this->IsDummy())
173+
{
174+
cout << "Atom (DUMMY) :"
175+
<< FormatString(this->GetName(),16) << " at : "
176+
<< FormatFloat(this->GetX())
177+
<< FormatFloat(this->GetY())
178+
<< FormatFloat(this->GetZ());
179+
}
179180
else
180181
{
181-
cout << ", Biso="
182+
cout << "Atom ("
183+
<< FormatString(mpScattPowAtom->GetSymbol(),4) << ") :"
184+
<< FormatString(this->GetName(),16) << " at : "
185+
<< FormatFloat(this->GetX())
186+
<< FormatFloat(this->GetY())
187+
<< FormatFloat(this->GetZ())
188+
<< ", Biso="
182189
<< FormatFloat(mpScattPowAtom->GetBiso())
183190
<< ", Popu=" << FormatFloat(this->GetOccupancy());
184191
}
@@ -303,6 +310,7 @@ void Atom::GLInitDisplayList(const bool onlyIndependentAtoms,
303310
const bool fullMoleculeInLimits)const
304311
{
305312
VFN_DEBUG_MESSAGE("Atom::GLInitDisplayList():"<<this->GetName(),5)
313+
if(this->IsDummy()) return ;
306314
REAL en=1;
307315
if(displayEnantiomer==true) en=-1;
308316

@@ -323,7 +331,6 @@ void Atom::GLInitDisplayList(const bool onlyIndependentAtoms,
323331
const REAL bb=this->GetCrystal().GetLatticePar(1);
324332
const REAL cc=this->GetCrystal().GetLatticePar(2);
325333

326-
if(this->IsDummy()) return ;
327334
if(hideHydrogens && (mpScattPowAtom->GetForwardScatteringFactor(RAD_XRAY)<1.5)) return;
328335
GLUquadricObj* pQuadric = gluNewQuadric();
329336
if(true==onlyIndependentAtoms)

src/ObjCryst/ObjCryst/CIF.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1171,8 +1171,10 @@ Crystal* CreateCrystalFromCIF(CIF &cif,const bool verbose,const bool checkSymAsX
11711171
if(verbose) cout<<endl<<"Finally using spacegroup name:"<<bestsymbol<<endl;
11721172
pCryst->GetSpaceGroup().ChangeSpaceGroup(bestsymbol);
11731173
}
1174+
// Try to set name from CIF. If that fails, the computed formula will be used at the end
11741175
if(pos->second.mName!="") pCryst->SetName(pos->second.mName);
11751176
else if(pos->second.mFormula!="") pCryst->SetName(pos->second.mFormula);
1177+
11761178
const float t1=chrono.seconds();
11771179
(*fpObjCrystInformUser)((boost::format("CIF: Create Crystal:%s(%s)(dt=%6.3fs)")%pCryst->GetName() % pCryst->GetSpaceGroup().GetName() % t1).str());
11781180

@@ -1277,6 +1279,7 @@ Crystal* CreateCrystalFromCIF(CIF &cif,const bool verbose,const bool checkSymAsX
12771279
}
12781280
(*fpObjCrystInformUser)((boost::format("CIF: finished connecting atoms (%u isolated atoms, %u molecules) (Crystal creation=%6.3fs total)") % ctat % ctmol % chrono.seconds()).str());
12791281
}
1282+
if(pCryst->GetName()=="") pCryst->SetName(pCryst->GetFormula());
12801283
}
12811284
return pCryst;
12821285
}
@@ -1299,6 +1302,7 @@ PowderPattern* CreatePowderPatternFromCIF(CIF &cif)
12991302
DiffractionDataSingleCrystal* CreateSingleCrystalDataFromCIF(CIF &cif, Crystal *pcryst)
13001303
{
13011304
DiffractionDataSingleCrystal* pData=NULL;
1305+
std::string name("");
13021306
for(map<string,CIFData>::iterator pos=cif.mvData.begin();pos!=cif.mvData.end();++pos)
13031307
{
13041308
if(pos->second.mH.numElements()>0)
@@ -1310,6 +1314,7 @@ DiffractionDataSingleCrystal* CreateSingleCrystalDataFromCIF(CIF &cif, Crystal *
13101314
{ // Use last Crystal created
13111315
pcryst=&(gCrystalRegistry.GetObj(gCrystalRegistry.GetNb()-1));
13121316
(*fpObjCrystInformUser)((boost::format("CIF: Importing SINGLE CRYSTAL DIFFRACTION data: using last Crystal structure as corresponding crystal [%s]") % pcryst->GetName().c_str()).str());
1317+
name = pcryst->GetName();
13131318
}
13141319
else
13151320
{
@@ -1320,6 +1325,7 @@ DiffractionDataSingleCrystal* CreateSingleCrystalDataFromCIF(CIF &cif, Crystal *
13201325
}
13211326
pData=new DiffractionDataSingleCrystal(*pcryst);
13221327
pData->SetHklIobs(pos->second.mH,pos->second.mK,pos->second.mL,pos->second.mIobs,pos->second.mSigma);
1328+
if(pData->GetName()=="") pData->SetName(name);
13231329
(*fpObjCrystInformUser)((boost::format("CIF: Imported SINGLE CRYSTAL DIFFRACTION data, with %d reflections") % pData->GetNbRefl()).str());
13241330
}
13251331
}

src/ObjCryst/ObjCryst/Crystal.cpp

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,11 +380,41 @@ void Crystal::Print(ostream &os)const
380380
const long genMult=this->GetSpaceGroup().GetNbSymmetrics();
381381
for(int i=0;i<mScattCompList.GetNbComponent();i++)
382382
nbAtoms += genMult * mScattCompList(i).mOccupancy * mScattCompList(i).mDynPopCorr;
383-
os << " Total number of components (atoms) in one unit cell : " << nbAtoms<<endl<<endl;
383+
os << " Total number of components (atoms) in one unit cell : " << nbAtoms<<endl
384+
<< " Chemical formula: "<< this->GetFormula() <<endl;
384385

385386
VFN_DEBUG_MESSAGE("Crystal::Print():End",5)
386387
}
387388

389+
std::string Crystal::GetFormula() const
390+
{
391+
this->GetScatteringComponentList();
392+
if(mScattCompList.GetNbComponent() == 0) return "";
393+
std::map<std::string,float> velts;
394+
for(unsigned int i=0; i<mScattCompList.GetNbComponent(); ++i)
395+
{
396+
const ScatteringComponent* psi = &mScattCompList(i);
397+
if(psi->mpScattPow == 0) continue;
398+
if(psi->mpScattPow->GetClassName().compare("ScatteringPowerAtom")!=0) continue;
399+
const ScatteringPowerAtom *pat=dynamic_cast<const ScatteringPowerAtom*>(psi->mpScattPow);
400+
string p=pat->GetSymbol();
401+
if(velts.count(p)==0)
402+
velts[p] = psi->mOccupancy * psi->mDynPopCorr ;
403+
else velts[p] += psi->mOccupancy * psi->mDynPopCorr;
404+
}
405+
stringstream s;
406+
s<<std::setprecision(2);
407+
for(std::map<std::string,float>::const_iterator pos=velts.begin();pos!=velts.end();++pos)
408+
{
409+
if(pos!=velts.begin()) s<<" ";
410+
float nb=pos->second;
411+
if((abs(nb)-nb)<0.01) s<<pos->first<<int(round(nb));
412+
else s<<pos->first<<nb;
413+
}
414+
return s.str();
415+
}
416+
417+
388418
CrystMatrix_REAL Crystal::GetMinDistanceTable(const REAL minDistance) const
389419
{
390420
VFN_DEBUG_MESSAGE("Crystal::MinDistanceTable()",5)

src/ObjCryst/ObjCryst/Crystal.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,9 @@ class Crystal:public UnitCell
189189
/// \todo one function to print on one line and a PrintLong() function
190190
/// \param os the stream to which the information is outputed (default=cout)
191191
void Print(ostream &os=cout) const;
192+
193+
/// Formula with atoms in alphabetic order
194+
std::string GetFormula() const;
192195

193196
/** \brief Minimum interatomic distance between all scattering components (atoms) in
194197
* the crystal.

src/ObjCryst/ObjCryst/Indexing.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include <time.h>
3131
#include "ObjCryst/RefinableObj/RefinableObj.h"
3232
#include "ObjCryst/RefinableObj/LSQNumObj.h"
33+
#include "ObjCryst/ObjCryst/PowderPattern.h"
3334
namespace ObjCryst
3435
{
3536
/** Different lattice types.

src/ObjCryst/ObjCryst/Molecule.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -937,6 +937,9 @@ void MolBondAngle::SetAtom3(MolAtom& at){mvpAtom[2]=&at;}
937937
//MolAtom& MolBondAngle::GetAtom1(){return *(mvpAtom[0]);}
938938
//MolAtom& MolBondAngle::GetAtom2(){return *(mvpAtom[1]);}
939939
//MolAtom& MolBondAngle::GetAtom3(){return *(mvpAtom[2]);}
940+
std::size_t MolBondAngle::size() const {return mvpAtom.size();}
941+
vector<MolAtom*>::const_iterator MolBondAngle::begin() const {return mvpAtom.begin();}
942+
vector<MolAtom*>::const_iterator MolBondAngle::end() const {return mvpAtom.end();}
940943
#ifdef __WX__CRYST__
941944
WXCrystObjBasic* MolBondAngle::WXCreate(wxWindow* parent)
942945
{
@@ -1294,6 +1297,9 @@ MolAtom& MolDihedralAngle::GetAtom1(){return *(mvpAtom[0]);}
12941297
MolAtom& MolDihedralAngle::GetAtom2(){return *(mvpAtom[1]);}
12951298
MolAtom& MolDihedralAngle::GetAtom3(){return *(mvpAtom[2]);}
12961299
MolAtom& MolDihedralAngle::GetAtom4(){return *(mvpAtom[3]);}
1300+
std::size_t MolDihedralAngle::size() const {return mvpAtom.size();}
1301+
vector<MolAtom*>::const_iterator MolDihedralAngle::begin() const {return mvpAtom.begin();}
1302+
vector<MolAtom*>::const_iterator MolDihedralAngle::end() const {return mvpAtom.end();}
12971303
#ifdef __WX__CRYST__
12981304
WXCrystObjBasic* MolDihedralAngle::WXCreate(wxWindow* parent)
12991305
{
@@ -2174,8 +2180,8 @@ std::string Molecule::GetFormula() const
21742180
if((*pos)->IsDummy()) continue;
21752181
string p=(*pos)->GetScatteringPower().GetSymbol();
21762182
if(velts.count(p)==0)
2177-
velts[(*pos)->GetScatteringPower().GetName()]=(*pos)->GetOccupancy();
2178-
else velts[(*pos)->GetScatteringPower().GetName()]+=(*pos)->GetOccupancy();
2183+
velts[p]=(*pos)->GetOccupancy();
2184+
else velts[p]+=(*pos)->GetOccupancy();
21792185
}
21802186
stringstream s;
21812187
s<<std::setprecision(2);

src/ObjCryst/ObjCryst/Molecule.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,7 @@ class MolBond:public Restraint
229229
void SetBondOrder(const REAL length);
230230
bool IsFreeTorsion()const;
231231
void SetFreeTorsion(const bool isInRing);
232+
232233
private:
233234
pair<MolAtom*,MolAtom*> mAtomPair;
234235
REAL mLength0,mDelta,mSigma;
@@ -316,6 +317,9 @@ class MolBondAngle:public Restraint
316317
MolAtom& GetAtom3();
317318
bool IsFlexible()const;
318319
void SetFlexible(const bool isInRing);
320+
std::size_t size() const;
321+
vector<MolAtom*>::const_iterator begin() const;
322+
vector<MolAtom*>::const_iterator end() const;
319323
private:
320324
/// The vector of the 3 atoms involved in the bond angle.
321325
vector<MolAtom*> mvpAtom;
@@ -408,6 +412,9 @@ class MolDihedralAngle:public Restraint
408412
MolAtom& GetAtom2();
409413
MolAtom& GetAtom3();
410414
MolAtom& GetAtom4();
415+
std::size_t size() const;
416+
vector<MolAtom*>::const_iterator begin() const;
417+
vector<MolAtom*>::const_iterator end() const;
411418
private:
412419
/// The vector of the 4 atoms involved in the bond angle.
413420
vector<MolAtom*> mvpAtom;

0 commit comments

Comments
 (0)