Skip to content

Commit 1ac3dcf

Browse files
committed
Merge branch 'drop-objcryst-workaround'
* drop check for ObjCryst inversion center bug * require libobjcryst 2017.2.1 or later Resolve #27.
2 parents 58afe78 + 7e558fb commit 1ac3dcf

2 files changed

Lines changed: 9 additions & 34 deletions

File tree

src/diffpy/srreal/ObjCrystStructureAdapter.cpp

Lines changed: 8 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,13 @@
2323
#include <cmath>
2424
#include <set>
2525

26+
#include <ObjCryst/version.h>
2627
#include <diffpy/srreal/ObjCrystStructureAdapter.hpp>
2728

29+
#if LIBOBJCRYST_VERSION < 2017002001000LL
30+
#error libdiffpy requires libobjcryst 2017.2.1 or later.
31+
#endif
32+
2833
using namespace std;
2934

3035
namespace diffpy {
@@ -56,34 +61,6 @@ getUij(const ObjCryst::ScatteringPower* sp)
5661
}
5762

5863

59-
bool isGetInversionCenterDoubled()
60-
{
61-
static int value_cached = 0;
62-
const int BIT_CACHED = 1;
63-
const int BIT_VALUE = 2;
64-
// short circuit when the flag is already cached
65-
if (BIT_CACHED & value_cached) {
66-
const bool rv = BIT_VALUE & value_cached;
67-
return rv;
68-
}
69-
ObjCryst::SpaceGroup sg129("P 4/n m m :1");
70-
const CrystVector_REAL xyzinv = sg129.GetInversionCenter();
71-
if (0.5 == xyzinv(0) && 0.5 == xyzinv(1) && 0 == xyzinv(2)) {
72-
value_cached |= BIT_VALUE;
73-
}
74-
else if (0.25 == xyzinv(0) && 0.25 == xyzinv(1) && 0 == xyzinv(2)) {
75-
value_cached &= ~BIT_VALUE;
76-
}
77-
else {
78-
const char* emsg =
79-
"Unexpected value of ObjCryst::SpaceGroup::GetInversionCenter()";
80-
throw logic_error(emsg);
81-
}
82-
value_cached |= BIT_CACHED;
83-
return isGetInversionCenterDoubled();
84-
}
85-
86-
8764
CrystalStructureAdapter::SymOpVector
8865
fetchSymmetryOperations(const ObjCryst::SpaceGroup& spacegroup)
8966
{
@@ -126,12 +103,10 @@ fetchSymmetryOperations(const ObjCryst::SpaceGroup& spacegroup)
126103
assert(spacegroup.IsCentrosymmetric());
127104
assert(nbsym == 2 * last);
128105
CrystVector_REAL xyzinv = spacegroup.GetInversionCenter();
129-
// get tinv the overall translation associated with inversion center.
130-
// fox-objcryst 2017.2 returns doubled coordinates for the inversion
131-
// center so the tinv is the same. Expect fixup which will require
132-
// doubling the tinv value here.
106+
// tinv is the overall translation associated with inversion center.
107+
// it is double the inversion center position.
133108
R3::Vector tinv(xyzinv(0), xyzinv(1), xyzinv(2));
134-
tinv *= isGetInversionCenterDoubled() ? 1.0 : 2.0;
109+
tinv *= 2.0;
135110
// now apply the inversion center here
136111
for (int i = 0, j = last; i < last; ++i, ++j)
137112
{

src/tests/test_helpers.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
// Resolve DIFFPYTESTSDIRPATH ------------------------------------------------
3232

3333
#ifndef DIFFPYTESTSDIRPATH
34-
#error "Compiler must define the DIFFPYTESTSDIRPATH macro."
34+
#error Compiler must define the DIFFPYTESTSDIRPATH macro.
3535
#endif
3636
#define STRINGIFY(m) STRINGIFY_BRAIN_DAMAGE(m)
3737
#define STRINGIFY_BRAIN_DAMAGE(m) #m

0 commit comments

Comments
 (0)