Commit 79d40e9a authored by mdurant's avatar mdurant

Bringing Vizschema plugin up to date with latest from Tech-X repository

git-svn-id: http://visit.ilight.com/svn/visit/trunk/src@17125 18c085ea-50e0-402c-830e-de6fd14e8384
parent 3a2f4de3
......@@ -77,7 +77,7 @@ void VsRegistry::remove(VsH5Group* group) {
allGroupsShort.erase(group->getShortName());
}
VsH5Group* VsRegistry::getGroup(std::string name) {
VsH5Group* VsRegistry::getGroup(const std::string& name) {
std::string fullName = makeCanonicalName(name);
std::map<std::string, VsH5Group*>::iterator it = allGroups.find(fullName);
......@@ -239,7 +239,7 @@ void VsRegistry::remove(VsH5Dataset* dataset) {
allDatasetsShort.erase(dataset->getShortName());
}
VsH5Dataset* VsRegistry::getDataset(std::string name) {
VsH5Dataset* VsRegistry::getDataset(const std::string& name) {
std::string fullName = makeCanonicalName(name);
std::map<std::string, VsH5Dataset*>::iterator it = allDatasets.find(fullName);
......@@ -383,7 +383,7 @@ void VsRegistry::remove(VsMesh* mesh) {
allMeshesShort.erase(mesh->getShortName());
}
VsMesh* VsRegistry::getMesh(std::string name) {
VsMesh* VsRegistry::getMesh(const std::string& name) {
std::string fullName = makeCanonicalName(name);
std::map<std::string, VsMesh*>::iterator it = allMeshes.find(fullName);
......@@ -434,7 +434,7 @@ void VsRegistry::getAllMeshNames(std::vector<std::string>& names) {
/************* MD MESHES **************/
VsMDMesh* VsRegistry::getMDMesh(std::string name) {
VsMDMesh* VsRegistry::getMDMesh(const std::string& name) {
// Make name fully qualified
std::string fullName = makeCanonicalName(name);
......@@ -587,7 +587,7 @@ void VsRegistry::remove(VsVariable* variable) {
allVariablesShort.erase(variable->getShortName());
}
VsVariable* VsRegistry::getVariable(std::string name) {
VsVariable* VsRegistry::getVariable(const std::string& name) {
std::string fullName = makeCanonicalName(name);
std::map<std::string, VsVariable*>::iterator it = allVariables.find(fullName);
......@@ -639,7 +639,7 @@ void VsRegistry::getAllVariableNames(std::vector<std::string>& names) {
/*********** MD VARIABLES ***************/
VsMDVariable* VsRegistry::getMDVariable(std::string name) {
VsMDVariable* VsRegistry::getMDVariable(const std::string& name) {
// Make name fully qualified
std::string fullName = makeCanonicalName(name);
......@@ -786,7 +786,7 @@ void VsRegistry::remove(VsVariableWithMesh* variable) {
allVariablesWithMeshShort.erase(variable->getShortName());
}
VsVariableWithMesh* VsRegistry::getVariableWithMesh(std::string name) {
VsVariableWithMesh* VsRegistry::getVariableWithMesh(const std::string& name) {
std::string fullName = makeCanonicalName(name);
std::map<std::string, VsVariableWithMesh*>::iterator it = allVariablesWithMesh.find(fullName);
......@@ -836,7 +836,8 @@ void VsRegistry::getAllVariableWithMeshNames(std::vector<std::string>& names) {
}
/******************* EXPRESSIONS ************************/
void VsRegistry::addExpression(std::string name, std::string value) {
void VsRegistry::addExpression(const std::string& name,
const std::string& value) {
//check for duplicates
std::map<std::string, std::string>::const_iterator it;
it = allExpressions.find(name);
......@@ -923,7 +924,9 @@ void VsRegistry::createComponents() {
VsLog::debugLog() <<"VsRegistry::createComponents() - Returning." <<std::endl;
}
void VsRegistry::registerComponent(std::string varName, int componentNumber, std::string userSuppliedName) {
void VsRegistry::registerComponent(const std::string& varName,
int componentNumber,
const std::string& userSuppliedName) {
//If the user supplied a name, try to use it
if (!userSuppliedName.empty()) {
......@@ -937,7 +940,9 @@ void VsRegistry::registerComponent(std::string varName, int componentNumber, std
}
}
bool VsRegistry::registerComponentInfo(std::string componentName, std::string varName, int componentNumber) {
bool VsRegistry::registerComponentInfo(const std::string& componentName,
const std::string& varName,
int componentNumber) {
//yes, I should use a std::hash_map for this
//first, look for a match and report failure if the name is already registered
......@@ -972,7 +977,8 @@ bool VsRegistry::registerComponentInfo(std::string componentName, std::string va
return true;
}
void VsRegistry::getComponentInfo(std::string componentName, NamePair* namePair) {
void VsRegistry::getComponentInfo(const std::string& componentName,
NamePair* namePair) {
//yes, I should use a std::hash_map for this
//look for a match and return the value if the name is registered
......@@ -990,7 +996,8 @@ void VsRegistry::getComponentInfo(std::string componentName, NamePair* namePair)
namePair->second = -1;
}
std::string VsRegistry::getComponentName(std::string varName, int componentNumber) {
std::string VsRegistry::getComponentName(const std::string& varName,
int componentNumber) {
for (unsigned int i = 0; i < componentNames.size(); i++) {
std::pair<std::string, NamePair > foundPair = componentNames[i];
NamePair tempNamePair = foundPair.second;
......@@ -1004,7 +1011,8 @@ std::string VsRegistry::getComponentName(std::string varName, int componentNumbe
return "";
}
void VsRegistry::getComponentInfo(std::string varName, int componentNumber, NamePair* namePair) {
void VsRegistry::getComponentInfo(const std::string& varName,
int componentNumber, NamePair* namePair) {
//yes, I should use a std::hash_map for this
NamePair tempNamePair;
......@@ -1026,7 +1034,8 @@ void VsRegistry::getComponentInfo(std::string varName, int componentNumber, Name
namePair->second = -1;
}
std::string VsRegistry::getOldComponentName(std::string varName, int componentIndex) {
std::string VsRegistry::getOldComponentName(const std::string& varName,
int componentIndex) {
//generates an old-style name for the component
//of the form "varName_index"
......
......@@ -40,7 +40,7 @@ public:
//DATASETS
void add(VsH5Dataset* obj);
void remove(VsH5Dataset* obj);
VsH5Dataset* getDataset(std::string name);
VsH5Dataset* getDataset(const std::string& name);
void deleteAllDatasets();
void writeAllDatasets();
int numDatasets();
......@@ -49,7 +49,7 @@ public:
//GROUPS
void add(VsH5Group* obj);
void remove(VsH5Group* obj);
VsH5Group* getGroup(std::string name);
VsH5Group* getGroup(const std::string& name);
void deleteAllGroups();
void writeAllGroups();
int numGroups();
......@@ -60,7 +60,7 @@ public:
//MESHES
void add(VsMesh* mesh);
void remove(VsMesh* mesh);
VsMesh* getMesh(std::string name);
VsMesh* getMesh(const std::string& name);
void getAllMeshNames(std::vector<std::string>& names);
void deleteAllMeshes();
void writeAllMeshes();
......@@ -71,25 +71,25 @@ public:
void remove(VsMDMesh* var);
void buildMDMeshes();
void writeAllMDMeshes();
VsMDMesh* getMDMesh(std::string name);
VsMDMesh* getMDMesh(const std::string& name);
VsMDMesh* getMDParentForMesh(const std::string& name);
VsMesh* findSubordinateMDMesh(const std::string& name);
void getAllMDMeshNames(std::vector<std::string>& names);
int numMDMeshes();
//VARIABLES
void add(VsVariable* mesh);
void remove(VsVariable* mesh);
VsVariable* getVariable(std::string name);
void add(VsVariable* variable);
void remove(VsVariable* variable);
VsVariable* getVariable(const std::string& name);
void getAllVariableNames(std::vector<std::string>& names);
void deleteAllVariables();
void writeAllVariables();
int numVariables();
//VARIABLES WITH MESH
void add(VsVariableWithMesh* mesh);
void remove(VsVariableWithMesh* mesh);
VsVariableWithMesh* getVariableWithMesh(std::string name);
void add(VsVariableWithMesh* variable);
void remove(VsVariableWithMesh* variable);
VsVariableWithMesh* getVariableWithMesh(const std::string& name);
void getAllVariableWithMeshNames(std::vector<std::string>& names);
void deleteAllVariablesWithMesh();
void writeAllVariablesWithMesh();
......@@ -100,24 +100,30 @@ public:
void remove(VsMDVariable* var);
void buildMDVars();
void writeAllMDVariables();
VsMDVariable* getMDVariable(std::string name);
VsMDVariable* getMDVariable(const std::string& name);
void getAllMDVariableNames(std::vector<std::string>& names);
int numMDVariables();
VsVariable* findSubordinateMDVar(const std::string& name);
//VsVars
void buildExpressions(VsH5Group* group);
void addExpression(std::string name, std::string value);
void addExpression(const std::string& name, const std::string& value);
void writeAllExpressions();
std::map<std::string, std::string>* getAllExpressions();
int numExpressions();
//Variable components
void getComponentInfo(std::string componentName, NamePair* namePair);
void getComponentInfo(std::string varName, int componentNumber, NamePair* namePair);
std::string getComponentName(std::string varName, int componentNumber);
std::string getOldComponentName(std::string varName, int componentIndex);
void registerComponent(std::string varName, int componentNumber, std::string userSuppliedName);
void getComponentInfo(const std::string& componentName,
NamePair* namePair);
void getComponentInfo(const std::string& varName,
int componentNumber, NamePair* namePair);
std::string getComponentName(const std::string& varName,
int componentNumber);
std::string getOldComponentName(const std::string& varName,
int componentIndex);
void registerComponent(const std::string& varName,
int componentNumber,
const std::string& userSuppliedName);
void createComponents();
//Time
......@@ -163,7 +169,10 @@ private:
// first element of pair is the user-specified name
// second element of pair is "true" component name
std::vector< std::pair<std::string, NamePair > > componentNames;
bool registerComponentInfo(std::string componentName, std::string varName, int componentNumber);
bool registerComponentInfo(const std::string& componentName,
const std::string& varName,
int componentNumber);
};
......
......@@ -20,6 +20,7 @@ std::string VsSchema::typeAtt ="vsType";
std::string VsSchema::kindAtt = "vsKind";
std::string VsSchema::meshAtt = "vsMesh";
std::string VsSchema::maskAtt = "vsMask";
std::string VsSchema::nodeOffsetAtt = "vsNodeOffset";
std::string VsSchema::centeringAtt ="vsCentering";
std::string VsSchema::indexOrderAtt = "vsIndexOrder";
......
......@@ -25,6 +25,7 @@ struct VsSchema {
static std::string kindAtt;
static std::string meshAtt;
static std::string maskAtt;
static std::string nodeOffsetAtt;
static std::string centeringAtt; // This is deprecated
static std::string cellOffsetAtt; // Instead of offsetAtt
static std::string indexOrderAtt; //component major/minor, index C/Fortran; compMinorC is default
......
......@@ -27,6 +27,11 @@ public:
virtual void getMeshDataDims(std::vector<int>& dims);
virtual void getNumMeshDims(std::vector<int>& dims);
/**
* Get the mask variable name
* @return name or empty string if no mask
*/
virtual std::string getMaskName();
private:
......
......@@ -68,7 +68,7 @@ bool isFloatType(hid_t dataType) {
return answer;
}
bool isIntegerType(hid_t dataType) {
bool isIntType(hid_t dataType) {
if (H5Tequal(dataType, H5T_NATIVE_INT)) {
return true;
}
......@@ -80,6 +80,42 @@ bool isIntegerType(hid_t dataType) {
return answer;
}
bool isShortType(hid_t dataType) {
if (H5Tequal(dataType, H5T_NATIVE_SHORT)) {
return true;
}
hid_t nativeType = H5Tget_native_type(dataType, H5T_DIR_ASCEND);
bool answer = H5Tequal(nativeType, H5T_NATIVE_SHORT);
H5Tclose(nativeType);
return answer;
}
bool isCharType(hid_t dataType) {
if (H5Tequal(dataType, H5T_NATIVE_CHAR)) {
return true;
}
hid_t nativeType = H5Tget_native_type(dataType, H5T_DIR_ASCEND);
bool answer = H5Tequal(nativeType, H5T_NATIVE_CHAR);
H5Tclose(nativeType);
return answer;
}
bool isUnsignedCharType(hid_t dataType) {
if (H5Tequal(dataType, H5T_NATIVE_UCHAR)) {
return true;
}
hid_t nativeType = H5Tget_native_type(dataType, H5T_DIR_ASCEND);
bool answer = H5Tequal(nativeType, H5T_NATIVE_UCHAR);
H5Tclose(nativeType);
return answer;
}
void printType(hid_t dataType) {
if (H5Tequal(dataType, H5T_IEEE_F64BE)) VsLog::debugLog() <<"H5T_IEEE_F64BE";
else if (H5Tequal(dataType, H5T_NATIVE_CHAR)) VsLog::debugLog() <<"H5T_NATIVE_CHAR";
......
......@@ -34,9 +34,48 @@ std::string makeCanonicalName(std::string path, std::string name);
// If the two object names are identical, returns the first
//std::string getClosestName(std::string name1, std::string name2, std::string target);
/**
* Check data type
* @param dataType HDF5 data type
* @return true if type is double
*/
bool isDoubleType(hid_t dataType);
/**
* Check data type
* @param dataType HDF5 data type
* @return true if type is float
*/
bool isFloatType(hid_t dataType);
bool isIntegerType(hid_t dataType);
/**
* Check data type
* @param dataType HDF5 data type
* @return true if type is int
*/
bool isIntType(hid_t dataType);
/**
* Check data type
* @param dataType HDF5 data type
* @return true if type is short
*/
bool isShortType(hid_t dataType);
/**
* Check data type
* @param dataType HDF5 data type
* @return true if type is char
*/
bool isCharType(hid_t dataType);
/**
* Check data type
* @param dataType HDF5 data type
* @return true if type is unsigned char
*/
bool isUnsignedCharType(hid_t dataType);
void printType(hid_t dataType);
// Break a string into pieces
......
......@@ -19,6 +19,8 @@
#include <vector>
#include <string>
#define __CLASS__ "VsVariable::"
VsVariable::VsVariable(VsH5Dataset* data):
VsRegistryObject(data->registry) {
indexOrder = VsSchema::compMinorCKey; //default
......@@ -30,6 +32,13 @@ VsVariable::VsVariable(VsH5Dataset* data):
dataset = data;
registry->add(this);
this->nodeOffsetAtt = NULL;
this->nodeOffsetMeshName = "";
this->nodeOffset.resize(3);
for (size_t i = 0; i < 3; ++i) {
this->nodeOffset[i] = 0;
}
}
VsVariable::~VsVariable() {
......@@ -99,11 +108,11 @@ std::string VsVariable::getFullName() {
}
// Find attribute by name, or return NULL if not found
VsH5Attribute* VsVariable::getAttribute(const std::string name) {
VsH5Attribute* VsVariable::getAttribute(const std::string& name) {
return dataset->getAttribute(name);
}
std::string VsVariable::getStringAttribute(const std::string name) {
std::string VsVariable::getStringAttribute(const std::string& name) {
VsH5Attribute* foundAtt = getAttribute(name);
if (foundAtt == NULL)
return "";
......@@ -117,6 +126,12 @@ void VsVariable::write() {
VsLog::debugLog() << " indexOrder = " << indexOrder << std::endl;
VsLog::debugLog() << " centering = " << centering << std::endl;
VsLog::debugLog() << " meshName = " << meshName << std::endl;
VsLog::debugLog() << " nodeOffsetMeshName = " << nodeOffsetMeshName << std::endl;
VsLog::debugLog() << " nodeOffset = ";
for (size_t i = 0; i < nodeOffset.size(); ++i) {
VsLog::debugLog() << nodeOffset[i] << " ";
}
VsLog::debugLog() << std::endl;
}
// Get user-specified component names
......@@ -155,7 +170,9 @@ bool VsVariable::initialize() {
std::string meshName;
meshNameAtt->getStringValue(&meshName);
this->meshName = makeCanonicalName(dataset->getPath(), meshName);
// if no offsets
this->nodeOffsetMeshName = this->meshName;
//Does mesh exist?
this->meshMeta = registry->getMesh(this->meshName);
if (!this->meshMeta) {
......@@ -184,13 +201,61 @@ bool VsVariable::initialize() {
centeringAtt->getStringValue(&(this->centering));
}
this->nodeOffsetAtt = dataset->getAttribute(VsSchema::nodeOffsetAtt);
if (this->nodeOffsetAtt) {
std::vector<float> nodeOffsetFloat(3, 0);
std::vector<int> nodeOffsetInt(3, 0);
herr_t err = this->nodeOffsetAtt->getDoubleVectorValue(&this->nodeOffset);
if (err < 0) {
herr_t err2 = this->nodeOffsetAtt->getFloatVectorValue(&nodeOffsetFloat);
if (err2 < 0) {
herr_t err3 = this->nodeOffsetAtt->getIntVectorValue(&nodeOffsetInt);
if (err3 < 0) {
VsLog::debugLog() << __CLASS__ << __FUNCTION__ << " " << __LINE__ << " "
<< "Cannot get vector nodeOffset." << std::endl;
}
else {
// nodeOffset is of type int vector
// cast into double vectot
for (size_t i = 0; i < nodeOffsetInt.size(); ++i) {
this->nodeOffset[i] = nodeOffsetInt[i];
}
}
}
else {
// nodeOffset is of type float vector
// cast into double vector
for (size_t i = 0; i < nodeOffsetFloat.size(); ++i) {
this->nodeOffset[i] = nodeOffsetFloat[i];
}
}
}
VsLog::debugLog() << __CLASS__ << __FUNCTION__ << " " << __LINE__ << " "
<< "vector nodeOffset is "
<< nodeOffset[0] << " "
<< nodeOffset[1] << " "
<< nodeOffset[2] << std::endl;
if (this->hasNodeOffset()) {
// create a new mesh whose name contains the offsets
std::ostringstream oss;
for (size_t i = 0; i < this->nodeOffset.size(); ++i) {
oss << "_" << this->nodeOffset[i];
}
this->nodeOffsetMeshName += "$_withNodeOffset" + oss.str();
}
VsLog::debugLog() << "VsVariable::initialize() node offset mesh is "
<< this->nodeOffsetMeshName << std::endl;
}
//Get user-specified labels for components
//labels is a comma-delimited list of strings
VsH5Attribute* componentNamesAtt = dataset->getAttribute(VsSchema::labelsAtt);
if (componentNamesAtt) {
std::string names;
componentNamesAtt->getStringValue(&names);
tokenize(names, ',', this->labelNames);
}
......@@ -313,3 +378,27 @@ void VsVariable::createComponents() {
}
}
}
std::vector<double> VsVariable::getNodeOffset() const
{
return this->nodeOffset;
}
bool VsVariable::hasNodeOffset() const
{
double sum = 0;
for (size_t i = 0; i < this->nodeOffset.size(); ++i) {
sum += std::abs(this->nodeOffset[i]);
}
if (sum == 0) {
return false;
}
else {
return true;
}
}
std::string VsVariable::getNodeOffsetMeshName() const
{
return this->nodeOffsetMeshName;
}
......@@ -54,9 +54,9 @@ public:
std::string getFullName();
/** Find attribute by name, or return NULL if not found */
VsH5Attribute* getAttribute(const std::string name);
VsH5Attribute* getAttribute(const std::string& name);
std::string getStringAttribute(const std::string name);
std::string getStringAttribute(const std::string& name);
/** Supply debugging output. */
virtual void write();
......@@ -77,6 +77,26 @@ public:
void createComponents();
size_t getNumComps();
/**
* Get the node offset
* @return offset array
*/
std::vector<double> getNodeOffset() const;
/**
* Inquire if field has node offsets
* @return true of field has node offsets
*/
bool hasNodeOffset() const;
/**
* Get the mesh name mangled with the node offsets
* @return meshName if there are no node offset, or
* meshName_withNodeOffset_<offset0>_<offset1>_<offset2>
* if there are offsets
*/
std::string getNodeOffsetMeshName() const;
protected:
VsVariable(VsH5Dataset* data);
......@@ -106,6 +126,15 @@ protected:
/** Fully qualified path to this object */
std::string path;
/** lower node offset array (optional) */
VsH5Attribute* nodeOffsetAtt;
/** node offsets with respect to base node */
std::vector<double> nodeOffset;
/** The name with the node offset mangled */
std::string nodeOffsetMeshName;
};
#endif /* VSVARIABLE_H_ */
......@@ -106,11 +106,11 @@ std::string VsVariableWithMesh::getFullName() {
}
// Find attribute by name, or return NULL if not found
VsH5Attribute* VsVariableWithMesh::getAttribute(const std::string name) {
VsH5Attribute* VsVariableWithMesh::getAttribute(const std::string& name) {
return dataset->getAttribute(name);
}
std::string VsVariableWithMesh::getStringAttribute(const std::string name) {
std::string VsVariableWithMesh::getStringAttribute(const std::string& name) {
std::string result("");
......
......@@ -67,10 +67,10 @@ public:
std::string getFullName();
/** Find attribute by name, or return NULL if not found. */
VsH5Attribute* getAttribute(const std::string name);
VsH5Attribute* getAttribute(const std::string& name);
/** Retrieve the value of the attribute with the given name */
std::string getStringAttribute(const std::string name);
std::string getStringAttribute(const std::string& name);
/** Retrieve the user-specified label for component number i */
std::string getLabel(unsigned int i);
......
This diff is collapsed.
......@@ -18,16 +18,20 @@
#ifndef VS_FILE_FORMAT_H
#define VS_FILE_FORMAT_H
#include <vtkUnsignedCharArray.h>
#include <vtkPoints.h>
#include <VsH5Dataset.h>
//#include <VsH5Reader.h>
#include <avtSTMDFileFormat.h>
#include <hdf5.h>
#include <visit-hdf5.h>
#include <map>
#include <string>
#include <vector>
// Forward references to minimize compilation
class vtkPoints;
class vtkUnsignedCharArray;
class vtkDataSet;
class vtkDataArray;
class avtDatabaseMetaData;
......@@ -186,6 +190,11 @@ class avtVsFileFormat: public avtSTMDFileFormat {
*/
std::vector<std::string> curveNames;
/**
* A list of virtual meshes, attached to staggered fields
*/
std::vector<std::string> nodeOffsetMeshes;
/**
* Set the axis labels for a mesh.
*
......@@ -198,7 +207,8 @@ class avtVsFileFormat: public avtSTMDFileFormat {
*/
vtkDataSet* getUniformMesh(VsUniformMesh*, bool, int*, int*, int*);
vtkDataSet* getRectilinearMesh(VsRectilinearMesh*, bool, int*, int*, int*);
vtkDataSet* getStructuredMesh(VsStructuredMesh*, bool, int*, int*, int*);
vtkDataSet* getStructuredMesh(VsStructuredMesh*, bool, int*, int*, int*,
const std::vector<double>&);
vtkDataSet* getUnstructuredMesh(VsUnstructuredMesh*, bool, int*, int*, int*);
vtkDataSet* getPointMesh(VsVariableWithMesh*, bool, int*, int*, int*);
vtkDataSet* getCurve(int domain, const std::string& name);
......@@ -229,6 +239,25 @@ class avtVsFileFormat: public avtSTMDFileFormat {
int *maxs,
int *strides,
bool isNodal = true );
template <typename TYPE>
void fillInMaskNodeArray(const std::vector<int>& gdims,
VsH5Dataset *mask, bool maskIsFortranOrder,
vtkUnsignedCharArray *maskedNodes);
void fillInMeshNameAndNodeOffset(const std::string& mangledName,
std::string& meshName,
std::vector<double>& nodeOffset) const;
void buildNodeOffsetMeshList();
template <typename TYPE>
void setStructuredMeshCoords(const std::vector<int>& gdims,
const TYPE* dataPtr,
const std::vector<double>& nodeOffset,
bool isFortranOrder,
vtkPoints* vpoints);
#else
avtVsFileFormat(const char* dfnm) : avtSTMDFileFormat(&dfnm, 1) {;};
......
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