diff -r cf4c3eefdead -r a369c6597982 src/backend/APT/APTFileIO.cpp
--- src/backend/APT/APTFileIO.cpp Sun Feb 05 14:33:21 2017 +0000
+++ src/backend/APT/APTFileIO.cpp Sun Feb 05 18:27:46 2017 +0000
@@ -24,7 +24,6 @@
#include "../../common/translation.h"
-
#include <cstring>
#include <new>
@@ -1123,7 +1122,7 @@
return 0;
}
-//Load a TAPSIM Binfile
+//Load a TAPSIM Binfile, which is the input geometry format for TAPSIM
unsigned int loadTapsimBinFile(const char *fileName, unsigned int &progress, ATOMIC_BOOL &wantAbort, vector<IonHit> &posIons)
{
ifstream f(fileName,std::ios::binary);
@@ -1136,7 +1135,7 @@
fileSize = f.tellg();
f.seekg(0,std::ios::beg);
- //TAPSIM's binary geometery input format is not totally clearly documented
+ //TAPSIM's binary geometry input format is not totally clearly documented
// but an example is provided. So best efforts are us.
std::string str;
@@ -1202,7 +1201,7 @@
return TAPSIM_ERR_FILE_FORMAT_FAIL;
}
- //Contrary to docuemntation, ids appear to be "short", not "unsigned int"
+ //Contrary to documentation, ids appear to be "short", not "unsigned int"
size_t recordSize=( (numbersPresent ? 1:0 )*sizeof(unsigned int) +
3*sizeof(float) + (idsPresent ?1:0)*sizeof(short));
@@ -1222,11 +1221,24 @@
//Transfer position data
#ifdef __LITTLE_ENDIAN__
h.setPos(Point3D((float*)(buffer)));
-#elif __BIG_ENDIAN__
- static_assert(false); //TODO: IMPLEMENT ME
-#endif
+
//assign the ID as the mass to charge
h.setMassToCharge(*( (short*)(buffer+12) ));
+#elif __BIG_ENDIAN__
+ {
+ Point3D pt((float*)(buffer));
+ pt.switchEndian();
+ h.setPos(pt);
+
+ uint16_t s;
+ s =*( (uint16_t*)(buffer+12) );
+ shortSwapBytes(s);
+
+
+
+ }
+
+#endif
posIons[ui]=h;
@@ -1291,7 +1303,7 @@
if(!flip)
{
- //Fkip the endinanness
+ //Flip the endinanness
for(size_t ui=0;ui<4;ui++)
floatSwapBytes(buffer+ui);
}
@@ -1300,7 +1312,7 @@
outF.write((char*)&intData,4);
intData=3;
- //Write out verion num as "3"
+ //Write out version num as "3"
outF.write((char*)&intData,4);
for(size_t ui=0;ui<nPoints;ui++)
@@ -1339,7 +1351,7 @@
TEST((ions[0].getPos().sqrDist(Point3D(1,1,0)) < sqrtf(std::numeric_limits<float>::epsilon())),"Checking read/write OK");
//Load using auto-detection of endinanness
- //Load, forcing assuming cont4ents are little endianness as requried
+ //Load, forcing assuming contents are little endianness as required
TEST(!LoadATOFile(filename.c_str(),ions,dummyProgress,wantAbort,1),"ATO load test (forced endianness)");
TEST(ions.size() == 100,"ion size check");
TEST((ions[0].getPos().sqrDist(Point3D(1,1,0)) < sqrtf(std::numeric_limits<float>::epsilon())),"checking read/write OK");
diff -r cf4c3eefdead -r a369c6597982 src/common/endianTest.h
--- src/common/endianTest.h Sun Feb 05 14:33:21 2017 +0000
+++ src/common/endianTest.h Sun Feb 05 18:27:46 2017 +0000
@@ -51,7 +51,7 @@
inline int is_littleendian() { return (*(char*)&ENDIAN_TEST) == 1 ;}
-
+//this may fail on some compilers??
inline void floatSwapBytes(float *inFloat)
{
//Use a union to avoid strict-aliasing error
@@ -69,5 +69,19 @@
*inFloat=fb.f;
}
+inline void shortSwapBytes(short *inShort)
+{
+ //Use a union to avoid strict-aliasing error
+ union ShortSwapUnion{
+ short s;
+ char c[2];
+ } ;
+ ShortSwapUnion sa,sb;
+ sa.s = *inShort;
+ sb.c[0] = sa.c[1];
+ sb.c[1] = sa.c[0];
+
+ *inShort=sb.s;
+}
#endif