Skip to content

Commit c71eb53

Browse files
committed
Merge branch 'upstream-objcryst'
* upstream-objcryst: Better GetFormula for Crystal and Molecule
2 parents f450240 + f60cf2e commit c71eb53

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

src/ObjCryst/ObjCryst/Crystal.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,11 @@ std::string Crystal::GetFormula() const
409409
{
410410
if(pos!=velts.begin()) s<<" ";
411411
float nb=pos->second;
412-
if(abs(round(nb)-nb)<0.005) s<<pos->first<<int(round(nb));
412+
if(abs(round(nb)-nb)<0.005)
413+
{
414+
if(int(round(nb))==1) s<<pos->first;
415+
else s<<pos->first<<int(round(nb));
416+
}
413417
else s<<pos->first<<nb;
414418
}
415419
return s.str();

src/ObjCryst/ObjCryst/Molecule.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2207,8 +2207,12 @@ std::string Molecule::GetFormula() const
22072207
{
22082208
if(pos!=velts.begin()) s<<" ";
22092209
float nb=pos->second;
2210-
if((abs(nb)-nb)<0.01) s<<pos->first<<int(round(nb));
2211-
else s<<pos->first<<nb;
2210+
if(abs(round(nb)-nb)<0.005)
2211+
{
2212+
if(int(round(nb))==1) s<<pos->first;
2213+
else s<<pos->first<<int(round(nb));
2214+
}
2215+
else s<<pos->first<<nb;
22122216
}
22132217
return s.str();
22142218
}

0 commit comments

Comments
 (0)