[cig-commits] r6836 - in short/3D/PyLith/trunk: libsrc/meshio
unittests/libtests/meshio
brad at geodynamics.org
brad at geodynamics.org
Wed May 9 21:23:16 PDT 2007
Author: brad
Date: 2007-05-09 21:23:16 -0700 (Wed, 09 May 2007)
New Revision: 6836
Modified:
short/3D/PyLith/trunk/libsrc/meshio/BinaryIO.cc
short/3D/PyLith/trunk/libsrc/meshio/GMVFileBinary.cc
short/3D/PyLith/trunk/unittests/libtests/meshio/test_meshio.cc
Log:
Fixed bugs in reading binary GMV file when need to flip endian type; setting endian type using WORDS_BIGENDIAN doesn't seem to be working.
Modified: short/3D/PyLith/trunk/libsrc/meshio/BinaryIO.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/meshio/BinaryIO.cc 2007-05-10 01:34:20 UTC (rev 6835)
+++ short/3D/PyLith/trunk/libsrc/meshio/BinaryIO.cc 2007-05-10 04:23:16 UTC (rev 6836)
@@ -17,12 +17,6 @@
#include <fstream> // USES std::ifstream
#include <assert.h> // USES assert()
-#if defined(WORDS_BIGENDIAN)
-#define NATIVE_BIG_ENDIAN
-#else
-#define NATIVE_LITTLE_ENDIAN
-#endif
-
// ----------------------------------------------------------------------
// Read fixed length string from file.
std::string
Modified: short/3D/PyLith/trunk/libsrc/meshio/GMVFileBinary.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/meshio/GMVFileBinary.cc 2007-05-10 01:34:20 UTC (rev 6835)
+++ short/3D/PyLith/trunk/libsrc/meshio/GMVFileBinary.cc 2007-05-10 04:23:16 UTC (rev 6836)
@@ -43,7 +43,7 @@
} // destructor
// ----------------------------------------------------------------------
-// Read ASCII GMV file.
+// Read binary GMV file.
void
pylith::meshio::GMVFileBinary::read(double_array* coordinates,
int_array* cells,
@@ -71,7 +71,7 @@
if (!(fin.is_open() && fin.good())) {
std::ostringstream msg;
msg
- << "Could not open ASCII GMV file '" << _filename
+ << "Could not open binary GMV file '" << _filename
<< "' for reading.";
throw std::runtime_error(msg.str());
} // if
@@ -102,7 +102,7 @@
} // read
// ----------------------------------------------------------------------
-// Write ASCII GMV file.
+// Write binary GMV file.
void
pylith::meshio::GMVFileBinary::write(const double_array& coordinates,
const int_array& cells,
@@ -141,6 +141,7 @@
} // if
} // _readHeader
+#include <iostream>
// ----------------------------------------------------------------------
void
pylith::meshio::GMVFileBinary::_readVertices(std::ifstream& fin,
@@ -204,7 +205,7 @@
cellStringCur[stringLen] = '\0';
fin.read((char*) &numCornersCur, sizeof(int));
if (_flipEndian)
- BinaryIO::swapByteOrder((char*) numCornersCur, 1, sizeof(int));
+ BinaryIO::swapByteOrder((char*) &numCornersCur, 1, sizeof(int));
if (0 != *numCorners) {
if (cellStringCur != cellString) {
std::ostringstream msg;
@@ -254,6 +255,8 @@
while("endvars" != varName && !fin.eof() && fin.good()) {
int varType = 0;
fin.read((char*) &varType, sizeof(int));
+ if (_flipEndian)
+ BinaryIO::swapByteOrder((char*) &varType, 1, sizeof(varType));
if (1 == varType) { // variable/attribute associated with vertices
float_array vals(numVertices);
fin.read((char*) &vals[0], sizeof(float)*numVertices);
@@ -281,8 +284,12 @@
while("endflag" != varName && !fin.eof() && fin.good()) {
int numFlags = 0;
fin.read((char*) &numFlags, sizeof(int));
+ if (_flipEndian)
+ BinaryIO::swapByteOrder((char*) &numFlags, 1, sizeof(numFlags));
int varType = 0;
fin.read((char*) &varType, sizeof(int));
+ if (_flipEndian)
+ BinaryIO::swapByteOrder((char*) &varType, 1, sizeof(varType));
for (int iFlag=0; iFlag < numFlags; ++iFlag) {
const int flagNameLen = 8;
std::string flagName = BinaryIO::readString(fin, flagNameLen);
@@ -314,8 +321,12 @@
int numMaterials = 0;
fin.read((char*) &numMaterials, sizeof(int));
+ if (_flipEndian)
+ BinaryIO::swapByteOrder((char*) &numMaterials, 1, sizeof(numMaterials));
int dataType = 0;
fin.read((char*) &dataType, sizeof(int));
+ if (_flipEndian)
+ BinaryIO::swapByteOrder((char*) &dataType, 1, sizeof(dataType));
for (int iMat=0; iMat < numMaterials; ++iMat) {
const int nameLen = 8;
Modified: short/3D/PyLith/trunk/unittests/libtests/meshio/test_meshio.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/test_meshio.cc 2007-05-10 01:34:20 UTC (rev 6835)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/test_meshio.cc 2007-05-10 04:23:16 UTC (rev 6836)
@@ -32,9 +32,6 @@
main(int argc,
char* argv[])
{ // main
- //journal::info_t info("meshiocubit");
- //info.activate();
-
CppUnit::TestResultCollector result;
try {
@@ -45,6 +42,9 @@
// Initialize Python
Py_Initialize();
+ journal::info_t info("gmvfile");
+ //info.activate();
+
// Create event manager and test controller
CppUnit::TestResult controller;
More information about the cig-commits
mailing list