Commit 06cafc92 authored by hrchilds's avatar hrchilds
Browse files

Update from May 20, 2005

git-svn-id: http://visit.ilight.com/svn/visit/trunk/src@474 18c085ea-50e0-402c-830e-de6fd14e8384
parent 87fabdd7
......@@ -142,12 +142,17 @@ avtFileFormat::TurnMaterialSelectionOn(const char *m)
// Programmer: Hank Childs
// Creation: February 23, 2001
//
// Modifications:
//
// Hank Childs, Fri Apr 1 08:48:50 PST 2005
// Use debug5 instead of debug1, since this isn't really a problem.
//
// ****************************************************************************
void
avtFileFormat::FreeUpResources(void)
{
debug1 << "Asked " << GetType() << " to free up resources, but it did not "
debug5 << "Asked " << GetType() << " to free up resources, but it did not "
<< "define how to do that." << endl;
}
......@@ -162,12 +167,17 @@ avtFileFormat::FreeUpResources(void)
// Programmer: Mark C. Miller
// Creation: February 23, 2004
//
// Modifications:
//
// Hank Childs, Fri Apr 1 08:48:50 PST 2005
// Use debug5 instead of debug1, since this isn't really a problem.
//
// ****************************************************************************
void
avtFileFormat::ActivateTimestep(void)
{
debug1 << "Asked " << GetType() << " to activate timestep, but it did not "
debug5 << "Asked " << GetType() << " to activate timestep, but it did not "
<< "define how to do that." << endl;
}
......
......@@ -17,7 +17,16 @@
TIF
bmp
BMP
sdt
SDT
spr
SPR
imgvol
</Extensions>
<Files components="E">
vtkStimulateReader.C
avtImageFileFormat.C
</Files>
<Attribute name="" purpose="" persistent="false" exportAPI="" exportInclude="">
</Attribute>
</Plugin>
......@@ -9,8 +9,8 @@
// Purpose:
// Returns the type of a Image database.
//
// Programmer: meredith -- generated by xml2info
// Creation: Tue Feb 22 14:39:26 PST 2005
// Programmer: childs -- generated by xml2info
// Creation: Fri Mar 18 09:54:18 PDT 2005
//
// ****************************************************************************
DatabaseType
......@@ -25,8 +25,8 @@ ImageCommonPluginInfo::GetDatabaseType()
// Purpose:
// Returns the default extensions for a Image database.
//
// Programmer: meredith -- generated by xml2info
// Creation: Tue Feb 22 14:39:26 PST 2005
// Programmer: childs -- generated by xml2info
// Creation: Fri Mar 18 09:54:18 PDT 2005
//
// ****************************************************************************
std::vector<std::string>
......@@ -49,6 +49,11 @@ ImageCommonPluginInfo::GetDefaultExtensions()
defaultExtensions.push_back("TIF");
defaultExtensions.push_back("bmp");
defaultExtensions.push_back("BMP");
defaultExtensions.push_back("sdt");
defaultExtensions.push_back("SDT");
defaultExtensions.push_back("spr");
defaultExtensions.push_back("SPR");
defaultExtensions.push_back("imgvol");
return defaultExtensions;
}
......@@ -66,8 +71,8 @@ ImageCommonPluginInfo::GetDefaultExtensions()
//
// Returns: A Image database from list.
//
// Programmer: meredith -- generated by xml2info
// Creation: Tue Feb 22 14:39:26 PST 2005
// Programmer: childs -- generated by xml2info
// Creation: Fri Mar 18 09:54:18 PDT 2005
//
// ****************************************************************************
avtDatabase *
......
This diff is collapsed.
// ************************************************************************* //
// avtImageFileFormat.h //
// ************************************************************************* //
......@@ -31,6 +30,9 @@
// Mark C. Miller, Tue Nov 9 13:41:33 PST 2004
// Removed unnused pointvarnames, pointvars. Added fext and CanCacheVariable
//
// Hank Childs, Fri Mar 18 11:41:04 PST 2005
// Added support for image volumes.
//
// Mark C. Miller, Tue May 17 18:48:38 PDT 2005
// Deleted a bunch of commented-out code that was hold-over from the
// plugin generation processes.
......@@ -45,6 +47,7 @@ class avtImageFileFormat : public avtSTSDFileFormat
virtual const char *GetType(void) { return "Image"; };
virtual void FreeUpResources(void);
virtual void ActivateTimestep(void);
virtual vtkDataSet *GetMesh(const char *);
virtual vtkDataArray *GetVar(const char *);
......@@ -57,20 +60,41 @@ class avtImageFileFormat : public avtSTSDFileFormat
std::vector<bool> *selectionsApplied);
protected:
std::string fname;
std::string fext;
std::string image_fext;
std::vector<std::vector<float> > cellvars;
std::vector<std::string> cellvarnames;
vtkImageData *image;
std::vector<avtDataSelection_p> selList;
std::vector<bool> *selsApplied;
bool haveInitialized;
bool haveImageVolume;
std::vector<std::string> subImages;
float zStart;
bool specifiedZStart;
float zStep;
bool specifiedZStep;
bool haveReadWholeImage;
int indexOfImageAlreadyRead;
int indexOfImageToRead;
float xStart, yStart;
float xStep, yStep;
void ReadInImage(void);
void ReadImageVolumeHeader(void);
void Initialize(void);
bool ProcessDataSelections(
int *xmin, int *xmax,
int *ymin, int *ymax);
virtual void PopulateDatabaseMetaData(avtDatabaseMetaData *);
vtkDataSet *GetImageVolumeMesh(const char *);
vtkDataSet *GetOneMesh(const char *);
vtkDataArray *GetImageVolumeVar(const char *);
vtkDataArray *GetOneVar(const char *);
};
......
// ************************************************************************* //
// vtkStimulateReader.C //
// ************************************************************************* //
#include <vtkStimulateReader.h>
#include <vtkImageData.h>
#include <vtkObjectFactory.h>
#include <vtkByteSwap.h>
#include <vtkPointData.h>
#include <sys/stat.h>
vtkCxxRevisionMacro(vtkStimulateReader, "$Revision: 1.30 $");
vtkStandardNewMacro(vtkStimulateReader);
vtkStimulateReader::vtkStimulateReader()
{
haveReadSPRFile = false;
validSPRFile = false;
}
vtkStimulateReader::~vtkStimulateReader()
{
;
}
void vtkStimulateReader::ExecuteInformation()
{
char spr_name[1024];
char sdt_name[1024];
GetFilenames(this->FileName, spr_name, sdt_name);
ReadSPRFile(spr_name);
this->DataExtent[0] = 0;
this->DataExtent[1] = dims[0]-1;
this->DataExtent[2] = 0;
this->DataExtent[3] = dims[1]-1;
this->SetDataScalarTypeToFloat();
SetDataByteOrderToLittleEndian();
this->vtkImageReader2::ExecuteInformation();
}
int vtkStimulateReader::OpenFile(void)
{
// Close file from any previous image
if (this->File)
{
this->File->close();
delete this->File;
this->File = NULL;
}
char spr_name[1024];
char sdt_name[1024];
if (!GetFilenames(this->FileName, spr_name, sdt_name))
{
vtkErrorMacro(<<"Could not open file, bad filename: " << this->FileName);
return 0;
}
struct stat fs;
if ( !stat( sdt_name, &fs) )
{
#ifdef _WIN32
this->File = new ifstream(sdt_name, ios::in | ios::binary);
#else
this->File = new ifstream(sdt_name, ios::in);
#endif
}
if (! this->File || this->File->fail())
{
vtkErrorMacro(<< "Initialize: Could not open file " << this->FileName);
return 0;
}
vtkDebugMacro(<< "Able to sucessfully open file " << this->FileName);
return 1;
}
bool vtkStimulateReader::GetFilenames(const char *one_file, char *spr_name,
char *sdt_name)
{
if (one_file == NULL)
return false;
int len = strlen(one_file);
if (len < 4)
return false;
bool isCaps = false;
bool hasSPR = false;
bool hasSDT = false;
if (strcmp(one_file + (len-4), ".spr") == 0)
hasSPR = true;
if (strcmp(one_file + (len-4), ".SPR") == 0)
{
hasSPR = true;
isCaps = true;
}
if (strcmp(one_file + (len-4), ".sdt") == 0)
hasSDT = true;
if (strcmp(one_file + (len-4), ".SDT") == 0)
{
hasSDT = true;
isCaps = true;
}
if (!hasSPR && !hasSDT)
{
vtkErrorMacro(<< one_file << " cannot be a Stimulate file, "
<< "no .spr or .sdt extension.");
return false;
}
strcpy(spr_name, one_file);
strcpy(sdt_name, one_file);
if (hasSPR)
if (isCaps)
strcpy(sdt_name + (len-4), ".SDT");
else
strcpy(sdt_name + (len-4), ".sdt");
else
if (isCaps)
strcpy(spr_name + (len-4), ".SPR");
else
strcpy(spr_name + (len-4), ".spr");
return true;
}
void vtkStimulateReader::ExecuteData(vtkDataObject *output)
{
if (!OpenFile())
{
vtkErrorMacro(<<"Unable to open file");
return;
}
// A lot of this work should be done by the base class. But it doesn't
// appear to be working/is very hard to interface to, so just do a little
// of the heavy lifting ourselves.
vtkImageData *data = AllocateOutputData(output);
vtkDataArray *scalars = data->GetPointData()->GetScalars();
scalars->SetNumberOfTuples(dims[0]*dims[1]);
void *ptr = scalars->GetVoidPointer(0);
File->read((char *)ptr, dims[0]*dims[1]*sizeof(float));
if (GetSwapBytes())
{
vtkByteSwap::SwapVoidRange(ptr, dims[0]*dims[1], sizeof(float));
}
}
int vtkStimulateReader::CanReadFile(const char* fname)
{
char spr_name[1024];
char sdt_name[1024];
if (GetFilenames(fname, spr_name, sdt_name))
{
vtkErrorMacro(<<"Cannot read file: invalid filename " << fname);
return 0;
}
ifstream sdt_file(sdt_name);
if (sdt_file.fail())
{
vtkErrorMacro(<<"Cannot read file: invalid sdt_file " << sdt_name);
return 0;
}
return ReadSPRFile(spr_name);
}
bool vtkStimulateReader::ReadSPRFile(const char *spr_name)
{
if (haveReadSPRFile)
return validSPRFile;
haveReadSPRFile = true;
validSPRFile = false;
ifstream spr_file(spr_name);
if (spr_file.fail())
{
vtkErrorMacro(<<"Unable to read SPR file " << spr_name << ": file "
<< "does not exist");
return false;
}
char line[1024];
spr_file.getline(line, 1024);
int ndims = atoi(line);
if (ndims != 2)
{
vtkErrorMacro(<<"Unable to read SPR file, ndims = " << ndims
<< " and must equal 2.");
return false;
}
spr_file.getline(line, 1024);
dims[0] = atoi(line);
if (dims[0] < 0)
{
vtkErrorMacro(<<"Unable to read SPR file, dims[0] = " << dims[0]
<< " and must be positive.");
return false;
}
spr_file.getline(line, 1024);
origin[0] = atof(line);
spr_file.getline(line, 1024);
step[0] = atof(line);
if (step[0] < 0.)
{
vtkErrorMacro(<<"Unable to read SPR file step in X is negative");
return false;
}
spr_file.getline(line, 1024);
dims[1] = atoi(line);
if (dims[1] < 0)
{
vtkErrorMacro(<<"Unable to read SPR file, dims[1] = " << dims[1]
<< " and must be positive.");
return false;
}
spr_file.getline(line, 1024);
origin[1] = atof(line);
spr_file.getline(line, 1024);
step[1] = atof(line);
if (step[1] < 0.)
{
vtkErrorMacro(<<"Unable to read SPR file step in Y is negative");
return false;
}
validSPRFile = true;
return validSPRFile;
}
// ************************************************************************* //
// vtkStimulateReader.h //
// ************************************************************************* //
#ifndef VTK_STIMULATE_READER_H
#define VTK_STIMULATE_READER_H
#include <vtkImageReader2.h>
// ****************************************************************************
// Class: vtkStimulateReader
//
// Purpose:
// Reads the "Stimulate" image format, which is what is generated by
// the NDE folks in Engineering.
//
// Programmer: Hank Childs
// Creation: March 17, 2005
//
// ****************************************************************************
class vtkStimulateReader : public vtkImageReader2
{
public:
static vtkStimulateReader *New();
vtkTypeRevisionMacro(vtkStimulateReader,vtkImageReader2);
int CanReadFile(const char* fname);
virtual const char* GetFileExtensions()
{
return ".sdt .spr .SDT .SPR";
}
virtual const char* GetDescriptiveName()
{
return "Stimulate";
}
void GetDimensions(int &x, int &y) { x = dims[0]; y = dims[1]; };
void GetOrigin(float &x, float &y) { x = origin[0]; y = origin[1]; };
void GetStep(float &x, float &y) { x = step[0]; y = step[1]; };
protected:
void ExecuteInformation();
void ExecuteData(vtkDataObject *);
virtual int OpenFile(void);
vtkStimulateReader();
~vtkStimulateReader();
private:
bool haveReadSPRFile;
bool validSPRFile;
int dims[2];
float origin[2];
float step[2];
vtkStimulateReader(const vtkStimulateReader&); // Not implemented.
void operator=(const vtkStimulateReader&); // Not implemented.
bool GetFilenames(const char *, char *spr_name, char *sdt_name);
bool ReadSPRFile(const char *);
};
#endif
......@@ -3,8 +3,10 @@
// ************************************************************************* //
#include <avtTruecolorFilter.h>
#include <vtkDataSet.h>
#include <vtkCellData.h>
#include <vtkDataSet.h>
#include <vtkPointData.h>
#include <vtkUnsignedCharArray.h>
......@@ -59,13 +61,17 @@ avtTruecolorFilter::~avtTruecolorFilter()
// Hank Childs, Wed Nov 10 11:33:59 PST 2004
// Fix memory leak.
//
// Hank Childs, Fri May 20 14:52:21 PDT 2005
// Add support for nodal colors.
//
// ****************************************************************************
vtkDataSet *
avtTruecolorFilter::ExecuteData(vtkDataSet *inDS, int, std::string)
{
// if we do not know the name of the data array to display, we cannot display it
if(variable_name == NULL)
// if we do not know the name of the data array to display,
// we cannot display it
if (variable_name == NULL)
return inDS;
vtkDataSet *outDS = (vtkDataSet *) inDS->NewInstance();
......@@ -73,10 +79,16 @@ avtTruecolorFilter::ExecuteData(vtkDataSet *inDS, int, std::string)
// convert RGB vectors into a RGBA unsigned char array
// and use these data as colors
bool isZonal = true;
vtkDataArray *vecdata = inDS->GetCellData()->GetArray(variable_name);
if(vecdata == NULL)
return inDS;
if(vecdata->GetNumberOfComponents() != 4)
if (vecdata == NULL)
{
vecdata = inDS->GetPointData()->GetArray(variable_name);
if (vecdata == NULL)
return inDS;
isZonal = false;
}
if (vecdata->GetNumberOfComponents() != 4)
return inDS;
vtkUnsignedCharArray *color_array = vtkUnsignedCharArray::New();
......@@ -84,8 +96,16 @@ avtTruecolorFilter::ExecuteData(vtkDataSet *inDS, int, std::string)
// Add scalar array to the output dataset and make it active
color_array->SetName("ucharColors");
outDS->GetCellData()->AddArray(color_array);
outDS->GetCellData()->SetActiveScalars("ucharColors");
if (isZonal)
{
outDS->GetCellData()->AddArray(color_array);
outDS->GetCellData()->SetActiveScalars("ucharColors");
}
else
{
outDS->GetPointData()->AddArray(color_array);
outDS->GetPointData()->SetActiveScalars("ucharColors");
}
color_array->Delete();
......@@ -96,19 +116,3 @@ avtTruecolorFilter::ExecuteData(vtkDataSet *inDS, int, std::string)
}
// ****************************************************************************
// Method: avtTruecolorFilter::RefashionDataObjectInfo
//
// Purpose:
// Allows the filter to change its output's data object information, which
// is a description of the data object.
//
// Programmer: Chris Wojtan
// Creation: Monday, June 15 2004
//
// ****************************************************************************
void
avtTruecolorFilter::RefashionDataObjectInfo(void)
{
}
......@@ -5,7 +5,6 @@
#ifndef AVT_Truecolor_FILTER_H
#define AVT_Truecolor_FILTER_H
#include <avtStreamer.h>
......@@ -24,6 +23,9 @@
// Added "variable_name" member variable
// Added SetVarName member function
//
// Hank Childs, Fri May 20 14:55:06 PDT 2005
// Remove RefashionDataObjectInfo (it was empty).
//
// ****************************************************************************
class avtTruecolorFilter : public avtStreamer
......@@ -40,9 +42,10 @@ class avtTruecolorFilter : public avtStreamer
protected:
virtual vtkDataSet *ExecuteData(vtkDataSet *, int, std::string);
virtual void RefashionDataObjectInfo(void);
const char *variable_name;
};
#endif
......@@ -58,6 +58,9 @@
// Use EXCEPTION1 macro instead of EXCEPTION0 ('5979) and also add skeleton
// for expressions and time ('4557).
//
// Hank Childs, Fri Mar 18 10:50:37 PST 2005
// Return type of GetAuxiliaryData is void *, not void &.
//
// Mark C. Miller, Tue May 17 18:48:38 PDT 2005
// Moved PopulateDatabaseMetaData method down to format specific classes
//
......@@ -755,7 +758,7 @@ class AVTGeneratorPlugin
h << " // This is used to return unconvention data -- ranging from material" << endl;
h << " // information to information about block connectivity." << endl;
h