Commit 55d93250 authored by Will Schroeder's avatar Will Schroeder
Browse files

ENH: Added meat.

parent f1cadb05
......@@ -26,7 +26,7 @@ Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 1993, 1994
#include "SGridSrc.hh"
#include "vlDataR.hh"
class vlStructuredGridReader : public vlStructuredGridSource, public vlDataReader
class vlStructuredGridReader : public vlStructuredGridSource
{
public:
vlStructuredGridReader();
......@@ -34,6 +34,9 @@ public:
char *GetClassName() {return "vlStructuredGridReader";};
void PrintSelf(ostream& os, vlIndent indent);
// overload because of vlDataReader ivar
unsigned long int GetMTime();
// Description:
// Specify file name of vl structured grid data file to read.
vlSetStringMacro(Filename);
......@@ -42,6 +45,7 @@ public:
protected:
void Execute();
char *Filename;
vlDataReader Reader;
};
......
......@@ -26,7 +26,7 @@ Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 1993, 1994
#include "SPtsSrc.hh"
#include "vlDataR.hh"
class vlStructuredPointsReader : public vlStructuredPointsSource, public vlDataReader
class vlStructuredPointsReader : public vlStructuredPointsSource
{
public:
vlStructuredPointsReader();
......@@ -34,6 +34,9 @@ public:
char *GetClassName() {return "vlStructuredPointsReader";};
void PrintSelf(ostream& os, vlIndent indent);
// overload because of vlDataReader ivar
unsigned long int GetMTime();
// Description:
// Specify file name of vl structured points data file to read.
vlSetStringMacro(Filename);
......@@ -42,6 +45,7 @@ public:
protected:
void Execute();
char *Filename;
vlDataReader Reader;
};
#endif
......
......@@ -26,7 +26,7 @@ Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 1993, 1994
#include "UGridSrc.hh"
#include "vlDataR.hh"
class vlUnstructuredGridReader : public vlUnstructuredGridSource, public vlDataReader
class vlUnstructuredGridReader : public vlUnstructuredGridSource
{
public:
vlUnstructuredGridReader();
......@@ -34,6 +34,9 @@ public:
char *GetClassName() {return "vlUnstructuredGridReader";};
void PrintSelf(ostream& os, vlIndent indent);
// overload because of vlDataReader ivar
unsigned long int GetMTime();
// Description:
// Specify file name of vl unstructured grid data file to read.
vlSetStringMacro(Filename);
......@@ -42,6 +45,7 @@ public:
protected:
void Execute();
char *Filename;
vlDataReader Reader;
};
......
......@@ -25,36 +25,43 @@ vlStructuredGridReader::~vlStructuredGridReader()
if ( this->Filename ) delete [] this->Filename;
}
unsigned long int vlStructuredGridReader::GetMTime()
{
unsigned long dtime = this->vlStructuredGridSource::GetMTime();
unsigned long rtime = this->Reader.GetMTime();
return (dtime > rtime ? dtime : rtime);
}
void vlStructuredGridReader::Execute()
{
FILE *fp;
int numPts=0;
int numPts=0, npts;
int retStat;
char line[257];
int npts;
vlDebugMacro(<<"Reading vl structured grid file...");
this->Initialize();
if ( !(fp=this->OpenVLFile(this->Filename, this->Debug)) ||
! this->ReadHeader(fp,this->Debug) )
if ( !(fp=this->Reader.OpenVLFile(this->Filename, this->Debug)) ||
! this->Reader.ReadHeader(fp,this->Debug) )
return;
//
// Read structured points specific stuff
//
if ( (retStat=fscanf(fp,"%s",line)) == EOF || retStat < 1 ) goto PREMATURE;
if ( (retStat=fscanf(fp,"%256s",line)) == EOF || retStat < 1 )
goto PREMATURE;
if ( !strncmp(this->LowerCase(line),"dataset",(unsigned long)7) )
if ( !strncmp(this->Reader.LowerCase(line),"dataset",(unsigned long)7) )
{
//
// Make sure we're reading right type of geometry
//
if ( (retStat=fscanf(fp,"%s",line)) == EOF || retStat < 1 )
if ( (retStat=fscanf(fp,"%256s",line)) == EOF || retStat < 1 )
goto PREMATURE;
if ( strncmp(this->LowerCase(line),"structured_grid",17) )
if ( strncmp(this->Reader.LowerCase(line),"structured_grid",17) )
{
vlReadErrorMacro(<< "Cannot read dataset type: " << line);
vlErrorMacro(<< "Cannot read dataset type: " << line);
return;
}
//
......@@ -62,10 +69,10 @@ void vlStructuredGridReader::Execute()
//
while (1)
{
if ( (retStat=fscanf(fp,"%s",line)) == EOF || retStat < 1 )
if ( (retStat=fscanf(fp,"%256s",line)) == EOF || retStat < 1 )
goto PREMATURE;
if ( ! strncmp(this->LowerCase(line),"dimensions",10) )
if ( ! strncmp(this->Reader.LowerCase(line),"dimensions",10) )
{
int dim[3];
if ( (retStat=fscanf(fp,"%d %d %d",dim, dim+1, dim+2)) == EOF
......@@ -76,15 +83,12 @@ void vlStructuredGridReader::Execute()
this->SetDimensions(dim);
}
else if ( ! strncmp(line,"points",12) )
else if ( ! strncmp(line,"points",6) )
{
int npts;
if ( (retStat=fscanf(fp,"%d",npts)) == EOF || retStat < 1 )
if ( (retStat=fscanf(fp,"%d", &npts)) == EOF || retStat < 1 )
goto PREMATURE;
if ( npts > 0 && npts != numPts )
this->ReadPoints(fp, (vlPointSet *)this, npts);
this->Reader.ReadPoints(fp, (vlPointSet *)this, npts);
}
else if ( ! strncmp(line, "point_data", 10) )
......@@ -122,15 +126,15 @@ void vlStructuredGridReader::Execute()
//
// Now read the point data
//
this->ReadPointData(fp, (vlDataSet *)this, numPts, this->Debug);
this->Reader.ReadPointData(fp, (vlDataSet *)this, numPts, this->Debug);
return;
PREMATURE:
vlReadErrorMacro(<< "Premature EOF");
vlErrorMacro(<< "Premature EOF");
return;
UNRECOGNIZED:
vlReadErrorMacro(<< "Unrecognized keyord: " << line);
vlErrorMacro(<< "Unrecognized keyord: " << line);
return;
}
......@@ -140,4 +144,5 @@ void vlStructuredGridReader::PrintSelf(ostream& os, vlIndent indent)
vlStructuredGridSource::PrintSelf(os,indent);
os << indent << "Filename: " << this->Filename << "\n";
this->Reader.PrintSelf(os,indent.GetNextIndent());
}
......@@ -25,6 +25,13 @@ vlStructuredPointsReader::~vlStructuredPointsReader()
if ( this->Filename ) delete [] this->Filename;
}
unsigned long int vlStructuredPointsReader::GetMTime()
{
unsigned long dtime = this->vlStructuredPointsSource::GetMTime();
unsigned long rtime = this->Reader.GetMTime();
return (dtime > rtime ? dtime : rtime);
}
void vlStructuredPointsReader::Execute()
{
FILE *fp;
......@@ -36,25 +43,26 @@ void vlStructuredPointsReader::Execute()
vlDebugMacro(<<"Reading vl structured points file...");
this->Initialize();
if ( !(fp=this->OpenVLFile(this->Filename, this->Debug)) ||
! this->ReadHeader(fp,this->Debug) )
if ( !(fp=this->Reader.OpenVLFile(this->Filename, this->Debug)) ||
! this->Reader.ReadHeader(fp,this->Debug) )
return;
//
// Read structured points specific stuff
//
if ( (retStat=fscanf(fp,"%s",line)) == EOF || retStat < 1 ) goto PREMATURE;
if ( (retStat=fscanf(fp,"%256s",line)) == EOF || retStat < 1 )
goto PREMATURE;
if ( !strncmp(this->LowerCase(line),"dataset",(unsigned long)7) )
if ( !strncmp(this->Reader.LowerCase(line),"dataset",(unsigned long)7) )
{
//
// Make sure we're reading right type of geometry
//
if ( (retStat=fscanf(fp,"%s",line)) == EOF || retStat < 1 )
if ( (retStat=fscanf(fp,"%256s",line)) == EOF || retStat < 1 )
goto PREMATURE;
if ( strncmp(this->LowerCase(line),"structured_points",17) )
if ( strncmp(this->Reader.LowerCase(line),"structured_points",17) )
{
vlReadErrorMacro(<< "Cannot read dataset type: " << line);
vlErrorMacro(<< "Cannot read dataset type: " << line);
return;
}
//
......@@ -63,10 +71,10 @@ void vlStructuredPointsReader::Execute()
numPts = this->GetNumberOfPoints(); // get default
while (1)
{
if ( (retStat=fscanf(fp,"%s",line)) == EOF || retStat < 1 )
if ( (retStat=fscanf(fp,"%256s",line)) == EOF || retStat < 1 )
goto PREMATURE;
if ( ! strncmp(this->LowerCase(line),"dimensions",10) )
if ( ! strncmp(this->Reader.LowerCase(line),"dimensions",10) )
{
int dim[3];
if ( (retStat=fscanf(fp,"%d %d %d",dim, dim+1, dim+2)) == EOF
......@@ -132,15 +140,15 @@ void vlStructuredPointsReader::Execute()
//
// Now read the point data
//
this->ReadPointData(fp, (vlDataSet *)this, numPts, this->Debug);
this->Reader.ReadPointData(fp, (vlDataSet *)this, numPts, this->Debug);
return;
PREMATURE:
vlReadErrorMacro(<< "Premature EOF");
vlErrorMacro(<< "Premature EOF");
return;
UNRECOGNIZED:
vlReadErrorMacro(<< "Unrecognized keyord: " << line);
vlErrorMacro(<< "Unrecognized keyord: " << line);
return;
}
......@@ -150,4 +158,5 @@ void vlStructuredPointsReader::PrintSelf(ostream& os, vlIndent indent)
vlStructuredPointsSource::PrintSelf(os,indent);
os << indent << "Filename: " << this->Filename << "\n";
this->Reader.PrintSelf(os,indent.GetNextIndent());
}
......@@ -25,9 +25,143 @@ vlUnstructuredGridReader::~vlUnstructuredGridReader()
if ( this->Filename ) delete [] this->Filename;
}
unsigned long int vlUnstructuredGridReader::GetMTime()
{
unsigned long dtime = this->vlUnstructuredGridSource::GetMTime();
unsigned long rtime = this->Reader.GetMTime();
return (dtime > rtime ? dtime : rtime);
}
void vlUnstructuredGridReader::Execute()
{
FILE *fp;
int numPts=0;
int retStat;
char line[257];
int npts, size, ncells;
vlCellArray *cells=NULL;
int *types=NULL;
vlDebugMacro(<<"Reading vl unsstructured grid...");
this->Initialize();
if ( !(fp=this->Reader.OpenVLFile(this->Filename, this->Debug)) ||
! this->Reader.ReadHeader(fp,this->Debug) )
return;
//
// Read unstructured grid specific stuff
//
if ( (retStat=fscanf(fp,"%256s",line)) == EOF || retStat < 1 )
goto PREMATURE;
if ( !strncmp(this->Reader.LowerCase(line),"dataset",(unsigned long)7) )
{
//
// Make sure we're reading right type of geometry
//
if ( (retStat=fscanf(fp,"%256s",line)) == EOF || retStat < 1 )
goto PREMATURE;
if ( strncmp(this->Reader.LowerCase(line),"unstructured_grid",17) )
{
vlErrorMacro(<< "Cannot read dataset type: " << line);
return;
}
//
// Might find points, cells, and cell types
//
while (1)
{
if ( (retStat=fscanf(fp,"%256s",line)) == EOF || retStat < 1 )
goto PREMATURE;
if ( ! strncmp(this->Reader.LowerCase(line),"points",6) )
{
if ( (retStat=fscanf(fp,"%d", &numPts)) == EOF || retStat < 1 )
goto PREMATURE;
this->Reader.ReadPoints(fp, (vlPointSet *)this, numPts);
}
else if ( ! strncmp(line,"cells",5) )
{
if ( (retStat=fscanf(fp,"%d %d", &ncells, &size)) == EOF || retStat < 2 )
goto PREMATURE;
cells = new vlCellArray;
this->Reader.ReadCells(fp, size, cells->WritePtr(ncells,size));
cells->WrotePtr();
if ( cells && types ) this->SetCells(types, cells);
}
else if ( ! strncmp(line,"cell_types",5) )
{
if ( (retStat=fscanf(fp,"%d", &ncells)) == EOF || retStat < 1 )
goto PREMATURE;
types = new int[ncells];
if ( this->Reader.GetFileType() == BINARY )
{
if ( fgets(line,256,fp) == NULL ) goto PREMATURE; //suck up newline
if ( fread(types,sizeof(int),ncells,fp) != ncells ) goto PREMATURE;
}
else //ascii
{
for (int i=0; i<size; i++)
{
if ((retStat=fscanf(fp,"%d",types[i])) == EOF || retStat < 1)
goto PREMATURE;
}
}
if ( cells && types ) this->SetCells(types, cells);
}
else if ( ! strncmp(line, "point_data", 10) )
{
if ( (retStat=fscanf(fp,"%d", &npts)) == EOF || retStat < 1 )
goto PREMATURE;
if ( npts != numPts )
{
vlErrorMacro(<<"Number of points don't match!");
return;
}
break; //out of this loop
}
else
goto UNRECOGNIZED;
}
}
else if ( !strncmp(line, "point_data", 10) )
{
if ( (retStat=fscanf(fp,"%d", &numPts)) == EOF || retStat < 1 )
goto PREMATURE;
numPts = 0;
vlWarningMacro(<<"Not reading any dataset geometry...");
}
else
goto UNRECOGNIZED;
//
// Now read the point data
//
this->Reader.ReadPointData(fp, (vlDataSet *)this, numPts, this->Debug);
if ( types ) delete [] types;
return;
PREMATURE:
vlErrorMacro(<< "Premature EOF");
return;
UNRECOGNIZED:
vlErrorMacro(<< "Unrecognized keyord: " << line);
return;
}
void vlUnstructuredGridReader::PrintSelf(ostream& os, vlIndent indent)
......@@ -35,4 +169,5 @@ void vlUnstructuredGridReader::PrintSelf(ostream& os, vlIndent indent)
vlUnstructuredGridSource::PrintSelf(os,indent);
os << indent << "Filename: " << this->Filename << "\n";
this->Reader.PrintSelf(os,indent.GetNextIndent());
}
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