Commit 5336c64b authored by bonnell's avatar bonnell
Browse files

Fix tecplot reader issue on Windows (merge from 2.10RC)

git-svn-id: http://visit.ilight.com/svn/visit/trunk/src@27587 18c085ea-50e0-402c-830e-de6fd14e8384
parent 2d628481
......@@ -67,6 +67,15 @@
#define TECPLOT_VERSION_7X(v) (v >= TECPLOT_71 && v <= 79)
#define TECPLOT_VERSION_104GE(v) (v >= TECPLOT_104)
#ifdef WIN32
#define FSEEK _fseeki64
#define FTELL _ftelli64
#else
#define FSEEK fseek
#define FTELL ftell
#endif
// ****************************************************************************
// Method: tecplot_reverse_endian32
//
......@@ -81,11 +90,13 @@
// Creation: Thu Jun 12 11:31:56 PDT 2008
//
// Modifications:
// Kathleen Biagas, Wed Oct 21, 2015
// Use long long for offsets, so large files can be read on Windows.
//
// ****************************************************************************
static void
tecplot_reverse_endian32(void *ptr, long dataSize)
tecplot_reverse_endian32(void *ptr, long long dataSize)
{
char *cptr = (char*)ptr;
char *end = cptr + dataSize;
......@@ -117,11 +128,13 @@ tecplot_reverse_endian32(void *ptr, long dataSize)
// Creation: Thu Jun 12 11:31:56 PDT 2008
//
// Modifications:
// Kathleen Biagas, Wed Oct 21, 2015
// Use long long for offsets, so large files can be read on Windows.
//
// ****************************************************************************
static void
tecplot_reverse_endian64(void *ptr, long dataSize)
tecplot_reverse_endian64(void *ptr, long long dataSize)
{
char *cptr = (char*)ptr;
char *end = cptr + dataSize;
......@@ -155,11 +168,13 @@ tecplot_reverse_endian64(void *ptr, long dataSize)
// Creation: Thu Jun 12 11:31:56 PDT 2008
//
// Modifications:
// Kathleen Biagas, Wed Oct 21, 2015
// Use long long for offsets, so large files can be read on Windows.
//
// ****************************************************************************
static void
tecplot_reverse_endian16(void *ptr, long dataSize)
tecplot_reverse_endian16(void *ptr, long long dataSize)
{
char *cptr = (char*)ptr;
char *end = cptr + dataSize;
......@@ -1853,28 +1868,28 @@ TecplotFEConnectivity::Read(FILE *f, const TecplotZone &zone,
// Calculate the sizes and offsets
if(data->zoneNumberForConnectivity == -1)
{
zoneConnectivityOffset = ftell(f);
zoneConnectivityOffset = FTELL(f);
zoneConnectivitySize = zone.GetNumElements() *
TecplotNumNodesForZoneType(zone.zoneType) * 4;
fseek(f, zoneConnectivitySize, SEEK_CUR);
FSEEK(f, zoneConnectivitySize, SEEK_CUR);
}
if(data->zoneNumberForConnectivity == -1 &&
zone.rawLocalFaceNeighbors > 0)
{
raw1to1FaceNeighborOffset = ftell(f);
raw1to1FaceNeighborOffset = FTELL(f);
raw1to1FaceNeighborSize = zone.GetNumElements() *
TecplotNumFacesForZoneType(zone.zoneType) * 4;
fseek(f, raw1to1FaceNeighborSize, SEEK_CUR);
FSEEK(f, raw1to1FaceNeighborSize, SEEK_CUR);
}
if(data->zoneNumberForConnectivity == -1 &&
zone.numUserDefinedNeighborConnections != 0)
{
faceNeighborConnectionOffset = ftell(f);
faceNeighborConnectionOffset = FTELL(f);
faceNeighborConnectionSize = zone.numUserDefinedNeighborConnections *
TecplotNumNodesForZoneType(zone.zoneType) * 4;
fseek(f, faceNeighborConnectionSize, SEEK_CUR);
FSEEK(f, faceNeighborConnectionSize, SEEK_CUR);
}
return true;
......@@ -2034,7 +2049,7 @@ TecplotDataRecord::Read(FILE *f, const TecplotZone &zone)
}
}
dataOffset = ftell(f);
dataOffset = FTELL(f);
debug4 << "Data offset after reading min/max pairs: " << dataOffset << endl;
// Now that we've read the main part of the variables, calculate offsets to
......@@ -2042,9 +2057,9 @@ TecplotDataRecord::Read(FILE *f, const TecplotZone &zone)
debug4 << "Zone = " << zone << endl;
debug4 << "num nodes = " << zone.GetNumNodes() << endl;
CalculateOffsets(zone);
fseek(f, connectivityOffset, SEEK_SET);
debug4 << "start of connectivity: " << ftell(f)
<< " (0x" << std::hex << ftell(f) << ")" << endl;
FSEEK(f, connectivityOffset, SEEK_SET);
debug4 << "start of connectivity: " << FTELL(f)
<< " (0x" << std::hex << FTELL(f) << ")" << endl;
// Read the connectivity
if(zone.zoneType == ORDERED)
......@@ -2055,8 +2070,8 @@ TecplotDataRecord::Read(FILE *f, const TecplotZone &zone)
else
connectivity = new TecplotPolyConnectivity;
connectivity->Read(f, zone, this);
debug4 << "after reading connectivity, offset=" << std::dec << ftell(f)
<< " (0x" << std::hex << ftell(f) << ")"
debug4 << "after reading connectivity, offset=" << std::dec << FTELL(f)
<< " (0x" << std::hex << FTELL(f) << ")"
<< std::dec << endl;
return true;
......@@ -2161,6 +2176,10 @@ operator << (ostream &os, const TecplotDataRecord &obj)
// * slowest moving index are not included.
// */
// Thus, I created a numItems variable
//
// Kathleen Biagas, Wed Oct 21, 2015
// Use long long for offsets, so large files can be read on Windows.
//
// ****************************************************************************
void
......@@ -2172,8 +2191,8 @@ TecplotDataRecord::CalculateOffsets(const TecplotZone &zone)
{
// Point data packing. Each variable value is stored one after the next
// in a record format.
long recordSize = 0;
long offset = 0;
long long recordSize = 0;
long long offset = 0;
for(size_t i = 0; i < variables.size(); ++i)
{
if (variables[i].zoneShareNumber >= 0)
......@@ -2226,7 +2245,7 @@ TecplotDataRecord::CalculateOffsets(const TecplotZone &zone)
{
int numNodes = zone.GetNumNodes();
int centering, numItems;
long offset = 0;
long long offset = 0;
for(size_t i = 0; i < variables.size(); ++i)
{
if (variables[i].zoneShareNumber >= 0)
......@@ -2561,7 +2580,7 @@ TecplotFile::Read(FILE *f)
#if 1 // for now
while(recordType != 299.f && !feof(f))
{
debug4 << "z=" << i << "/" << zones.size() << ", Error reading recordType: " << recordType << " offset=" << ftell(f) << endl;
debug4 << "z=" << i << "/" << zones.size() << ", Error reading recordType: " << recordType << " offset=" << FTELL(f) << endl;
recordType = ReadFloat(f);
}
if(feof(f))
......@@ -2732,28 +2751,30 @@ TecplotFile::EnsureUniqueZoneNames()
// Creation: Thu Jun 12 11:42:17 PDT 2008
//
// Modifications:
// Kathleen Biagas, Wed Oct 21, 2015
// Use long long for offsets, so large files can be read on Windows.
//
// ****************************************************************************
bool
TecplotFile::ReadData(long dataOffset, long dataSize, TecplotDataType dataType,
TecplotFile::ReadData(long long dataOffset, long long dataSize, TecplotDataType dataType,
int dataPacking, int nnodes, void *ptr)
{
bool retval = false;
if((tec = fopen(fileName.c_str(), "rb")) != 0)
{
fseek(tec, dataOffset, SEEK_SET);
FSEEK(tec, dataOffset, SEEK_SET);
if(dataPacking == 1)
{
// Read the part of the record that we care about.
int nBytes = TecplotNumBytesForType(dataType);
char *cptr = (char *)ptr;
long skip = dataSize - nBytes;
long long skip = dataSize - nBytes;
for(int i = 0; i < nnodes; ++i)
{
size_t res = fread(cptr, 1, nBytes, tec); (void) res;
fseek(tec, skip, SEEK_CUR);
FSEEK(tec, skip, SEEK_CUR);
cptr += nBytes;
}
}
......@@ -2871,6 +2892,8 @@ TecplotFile::ReadVariable(int zoneId, const std::string &varName, void *ptr)
// Creation: Thu Jun 12 11:45:57 PDT 2008
//
// Modifications:
// Kathleen Biagas, Wed Oct 21, 2015
// Use long long for offsets, so large files can be read on Windows.
//
// ****************************************************************************
......@@ -2889,7 +2912,7 @@ TecplotFile::ReadVariableAsFloat(int zoneId, const std::string &varName, float *
retval = ReadVariable(zoneId, varName, ptr);
else
{
long dataSize;
long long dataSize;
unsigned int N = (unsigned int)zones[zoneId].GetNumNodes();
if(zones[zoneId].dataPacking == 1)
dataSize = N * TecplotNumBytesForType(var.dataType);
......
......@@ -689,7 +689,9 @@ int TecplotNumBytesForType(TecplotDataType dt);
// Creation: Thu Jun 12 11:22:42 PDT 2008
//
// Modifications:
//
// Kathleen Biagas, Wed Oct 21, 2015
// Use long long for offsets, so large files can be read on Windows.
//
// ****************************************************************************
class TecplotVariable
......@@ -698,8 +700,8 @@ public:
TecplotVariable();
virtual ~TecplotVariable();
long dataOffset;
long dataSize;
long long dataOffset;
long long dataSize;
TecplotDataType dataType;
int isPassive;
......@@ -751,6 +753,8 @@ private:
// Creation: Thu Jun 12 11:24:14 PDT 2008
//
// Modifications:
// Kathleen Biagas, Wed Oct 21, 2015
// Use long long for offsets, so large files can be read on Windows.
//
// ****************************************************************************
......@@ -765,8 +769,8 @@ public:
virtual bool Read(FILE *f, const TecplotZone &, const TecplotDataRecord *);
virtual bool Write(FILE *f);
long connectivityOffset;
long connectivitySize;
long long connectivityOffset;
long long connectivitySize;
};
// ****************************************************************************
......@@ -782,6 +786,8 @@ public:
// Creation: Thu Jun 12 11:24:14 PDT 2008
//
// Modifications:
// Kathleen Biagas, Wed Oct 21, 2015
// Use long long for offsets, so large files can be read on Windows.
//
// ****************************************************************************
......@@ -796,13 +802,13 @@ public:
virtual bool Read(FILE *f, const TecplotZone &, const TecplotDataRecord *);
virtual bool Write(FILE *f);
long zoneConnectivitySize;
long raw1to1FaceNeighborSize;
long faceNeighborConnectionSize;
long long zoneConnectivitySize;
long long raw1to1FaceNeighborSize;
long long faceNeighborConnectionSize;
long zoneConnectivityOffset;
long raw1to1FaceNeighborOffset;
long faceNeighborConnectionOffset;
long long zoneConnectivityOffset;
long long raw1to1FaceNeighborOffset;
long long faceNeighborConnectionOffset;
};
// ****************************************************************************
......@@ -847,6 +853,8 @@ public:
// Creation: Thu Jun 12 11:25:57 PDT 2008
//
// Modifications:
// Kathleen Biagas, Wed Oct 21, 2015
// Use long long for offsets, so large files can be read on Windows.
//
// ****************************************************************************
......@@ -862,8 +870,8 @@ public:
virtual bool Write(FILE *f);
// In-memory-only data
long dataOffset;
long connectivityOffset;
long long dataOffset;
long long connectivityOffset;
// Data from file
std::vector<TecplotVariable> variables;
......@@ -892,6 +900,9 @@ private:
// Kathleen Bonnell, Thu Jun 26 10:29:17 PDT 2008
// Changed return type of DisableReadingDataInformation from bool to void.
//
// Kathleen Biagas, Wed Oct 21, 2015
// Use long long for offsets, so large files can be read on Windows.
//
// ****************************************************************************
class TecplotFile : public TecplotBase
......@@ -931,7 +942,7 @@ public:
bool ReadFEConnectivity(int zoneId, int **conn);
protected:
bool ReadData(long dataOffset, long dataSize, TecplotDataType dataType,
bool ReadData(long long dataOffset, long long dataSize, TecplotDataType dataType,
int dataPacking, int nnodes, void *ptr);
void EnsureUniqueZoneNames();
......
......@@ -25,7 +25,7 @@ enhancements and bug-fixes that were added to this release.</p>
<p><b><font size="4">Bugs fixed in version 2.10.1</font></b></p>
<ul>
<li>The <i>VisItAddPlot()</i> function in Libsim was incorrectly using the global <i>"Apply operators to all plots"</i> setting when creating plots. The behavior for VisItAddPlot() has been changed so new plots are not created with previously applied operators to more closely match the operation of the VisIt CLI.</li>
<li></li>
<li>Large tecplot files could not be read on Windows.</li>
<li></li>
<li></li>
</ul>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment