Commit 40d83184 authored by mdurant's avatar mdurant

Adding support for transformed meshes (we automatically transform z-r-phi...

Adding support for transformed meshes (we automatically transform z-r-phi cylindrical into cartesian).  Also removing the node-offset-mesh feature, which has been replaced with the offset filter & operator (still in progress)

git-svn-id: http://visit.ilight.com/svn/visit/trunk/src@17995 18c085ea-50e0-402c-830e-de6fd14e8384
parent 83224ca3
......@@ -63,7 +63,7 @@ VsH5Reader::VsH5Reader(const std::string& nm, VsRegistry* r) {
registry = r;
// Read metadata
// Read raw hdf5 metadata
fileData = VsFilter::readFile(registry, nm);
if (!fileData) {
VsLog::errorLog() << __CLASS__ << __FUNCTION__ << " " << __LINE__ << " "
......@@ -71,7 +71,7 @@ VsH5Reader::VsH5Reader(const std::string& nm, VsRegistry* r) {
EXCEPTION1(InvalidFilesException, nm.c_str());
}
//debugging output
//debugging output of raw hdf5 objects
registry->writeAllGroups();
registry->writeAllDatasets();
......@@ -82,6 +82,10 @@ VsH5Reader::VsH5Reader(const std::string& nm, VsRegistry* r) {
//Build MD objects
registry->buildMDMeshes();
registry->buildMDVars();
//Register "transformed" meshes, and then variables
registry->buildTransformedMeshes();
registry->buildTransformedVariables();
//debugging output
registry->writeAllMeshes();
......
......@@ -44,6 +44,62 @@ VsMesh::~VsMesh() {
registry->remove(this);
}
bool VsMesh::hasTransform() {
std::string transformName = getTransformName();
if ((transformName == VsSchema::zrphiTransformKey) && (numSpatialDims == 3)) {
return true;
} else if ((transformName == VsSchema::zrphiTransformKey_deprecated) && (numSpatialDims == 3)) {
return true;
}
return false;
}
std::string VsMesh::getTransformName() {
//Look for the vsTransform attribute
//and either retrieve the value or leave the name empty
std::string transformName;
VsH5Attribute* transformNameAtt = getAttribute(VsSchema::transformKey);
if (transformNameAtt) {
transformNameAtt->getStringValue(&transformName);
}
//Make sure this is a recognized value
//All other methods use the return value of this method as a go/no-go test
//So this is the best place to catch bad values
if ((transformName != VsSchema::zrphiTransformKey) &&
(transformName != VsSchema::zrphiTransformKey_deprecated)) {
VsLog::errorLog() <<"VsMesh::getTransformName() - Unrecognized value for key "
<< VsSchema::transformKey << " - " <<transformName <<std::endl;
transformName = "";
}
return transformName;
}
std::string VsMesh::getTransformedMeshName() {
//Look for the vsTransformName key
std::string transformedMeshName;
VsH5Attribute* transformedMeshNameAtt = getAttribute(VsSchema::transformedMeshKey);
if (transformedMeshNameAtt) {
transformedMeshNameAtt->getStringValue(&transformedMeshName);
if (!transformedMeshName.empty()) {
//We want to make the tranformed mesh appear at the same file level
//as the original mesh.
//So, when we calculate the canonical name, use the PATH, not the FULL NAME
transformedMeshName = makeCanonicalName(getPath(), transformedMeshName);
}
}
// if we didn't find a user supplied name, create a name
if (transformedMeshName.empty()) {
transformedMeshName = getFullName() + "_transform";
transformedMeshName = makeCanonicalName(transformedMeshName);
}
return transformedMeshName;
}
bool VsMesh::isFortranOrder() {
return ((indexOrder == VsSchema::compMinorFKey) ||
(indexOrder == VsSchema::compMajorFKey));
......
......@@ -61,6 +61,10 @@ public:
void setMDMesh(VsMDMesh* mdMesh, int dNumber);
int getDomainNumber();
VsMDMesh* getMDMesh();
virtual bool hasTransform();
virtual std::string getTransformName();
virtual std::string getTransformedMeshName();
protected:
VsMesh(VsH5Object* object);
......
......@@ -199,7 +199,6 @@ std::string VsRectilinearMesh::getAxisDatasetName(int axisNumber) {
return makeCanonicalName(getFullName(), axisName);
}
VsH5Dataset* VsRectilinearMesh::getAxisDataset(int axisNumber) {
std::string axisDatasetName = getAxisDatasetName(axisNumber);
if (axisDatasetName.empty()) {
......@@ -211,60 +210,10 @@ VsH5Dataset* VsRectilinearMesh::getAxisDataset(int axisNumber) {
return answer; //could be NULL
}
std::string VsRectilinearMesh::getKind() {
return VsSchema::Rectilinear::key;
}
bool VsRectilinearMesh::hasTransform() {
return (!getTransformName().empty());
}
std::string VsRectilinearMesh::getTransformName() {
//Look for the vsTransform attribute
//and either retrieve the value or leave the name empty
std::string transformName;
VsH5Attribute* transformNameAtt = getAttribute(VsSchema::Rectilinear::transformKey);
if (transformNameAtt) {
transformNameAtt->getStringValue(&transformName);
}
//Make sure this is a recognized value
//All other methods use the return value of this method as a go/no-go test
//So this is the best place to catch bad values
if (transformName != VsSchema::Rectilinear::zrphiTransformKey) {
VsLog::errorLog() <<"VsRectilinearMesh::getTransformName() - Unrecognized value for key "
<< VsSchema::Rectilinear::transformKey << " - " <<transformName <<std::endl;
transformName = "";
}
return transformName;
}
std::string VsRectilinearMesh::getTransformedMeshName() {
//Look for the vsTransformName key
std::string transformedMeshName;
VsH5Attribute* transformedMeshNameAtt = getAttribute(VsSchema::Rectilinear::transformedMeshKey);
if (transformedMeshNameAtt) {
transformedMeshNameAtt->getStringValue(&transformedMeshName);
if (!transformedMeshName.empty()) {
//We want to make the tranformed mesh appear at the same file level
//as the original mesh.
//So, when we calculate the canonical name, use the PATH, not the FULL NAME
transformedMeshName = makeCanonicalName(getPath(), transformedMeshName);
}
}
// if we didn't find a user supplied name, create a name
if (transformedMeshName.empty()) {
transformedMeshName = getFullName() + "_transform";
transformedMeshName = makeCanonicalName(transformedMeshName);
}
return transformedMeshName;
}
void VsRectilinearMesh::getMeshDataDims(std::vector<int>& dims)
{
VsLog::debugLog() << __CLASS__ << __FUNCTION__ << " " << __LINE__ << " "
......
......@@ -25,12 +25,6 @@ public:
std::string getAxisDatasetName(int axisNumber);
VsH5Dataset* getAxisDataset(int axisNumber);
// Roopa: These two methods are used to access the vsTransform and
// vsTransformedMesh fields
bool hasTransform();
std::string getTransformName();
std::string getTransformedMeshName();
virtual bool isRectilinearMesh() { return true; }
static VsRectilinearMesh* buildRectilinearMesh(VsH5Group* group);
......
......@@ -556,7 +556,47 @@ void VsRegistry::buildMDMeshes() {
VsLog::debugLog() <<"VsRegistry::buildMDMeshes() - Exiting." <<std::endl;
}
/*********** VARIBLES ***********/
/*********** TRANSFORMED VARIABLES ****************************/
void VsRegistry::buildTransformedVariables() {
std::map<std::string, VsVariable*>::const_iterator it;
for (it = allVariables.begin(); it != allVariables.end(); ++it) {
VsLog::debugLog() <<"VsRegistry::buildTransformedVariables() - Creating transform names for Variable " <<it->first <<std::endl;
it->second->createTransformedVariable();
}
std::map<std::string, VsVariableWithMesh*>::const_iterator it2;
for (it2 = allVariablesWithMesh.begin(); it2 != allVariablesWithMesh.end(); ++it2) {
VsLog::debugLog() <<"VsRegistry::buildTransformedVariables() - Creating transform names for Variable with Mesh " <<it2->first <<std::endl;
it2->second->createTransformedVariableAndMesh();
}
}
/*********** TRANSFORMED MESHES *******************************/
void VsRegistry::buildTransformedMeshes() {
//go through all meshes looking for "vsTransform" flags
VsLog::debugLog() <<"VsRegistry::buildTransformedMeshes() - Entering." <<std::endl;
// Roopa: Check if there is a transformation specified for this
// mesh. If so, register the transformed mesh here
std::map<std::string, VsMesh*>::const_iterator it;
for (it = allMeshes.begin(); it != allMeshes.end(); it++) {
VsLog::debugLog() <<"VsRegistry::buildTransformedMeshes() - examining mesh " <<(*it).first <<std::endl;
VsMesh* mesh = (*it).second;
if (!mesh) {
VsLog::errorLog() <<"VsRegistry::buildTransformedMeshes() - mesh is NULL?" <<std::endl;
continue;
}
if (mesh->hasTransform()) {
std::string transformedMeshName = mesh->getTransformedMeshName();
VsLog::debugLog() <<"VsRegistry::buildTransformedMeshes() - mesh " <<(*it).first <<" has transformed mesh " <<transformedMeshName <<std::endl;
registerTransformedMeshName(transformedMeshName, mesh->getFullName());
}
}
VsLog::debugLog() <<"VsRegistry::buildTransformedMeshes() - Returning." <<std::endl;
}
/*********** VARIABLES ***********/
void VsRegistry::add(VsVariable* variable) {
//check for duplicate long name
VsVariable* foundVariable = this->getVariable(variable->getFullName());
......@@ -846,7 +886,7 @@ bool VsRegistry::registerTransformedMeshName(std::string transformedName, std::s
<< oName << std::endl;
return false;
} else {
VsLog::debugLog() << "VsRegistry::registerTransformedMeshName() - recieved duplicate registration for "
VsLog::debugLog() << "VsRegistry::registerTransformedMeshName() - received duplicate registration for "
<< origName << std::endl;
VsLog::debugLog() << "VsRegistry::registerTransformedMeshName() - but all info matches, so it should be ok"
<< std::endl;
......@@ -914,7 +954,7 @@ void VsRegistry::addExpression(const std::string& name,
}
/**
* VsRegistry::buildbuildExpressions()
* VsRegistry::buildExpressions()
*
* A "VsVars" group represents a set of names and values
* Each attribute in the group represents one expression
......@@ -981,7 +1021,7 @@ void VsRegistry::createComponents() {
std::map<std::string, VsVariableWithMesh*>::const_iterator it3;
for (it3 = allVariablesWithMesh.begin(); it3 != allVariablesWithMesh.end(); ++it3) {
VsLog::debugLog() <<"VsRegistry::createComponents() - Creating components for Variable With Mesh" <<it3->first <<std::endl;
VsLog::debugLog() <<"VsRegistry::createComponents() - Creating components for Variable With Mesh " <<it3->first <<std::endl;
it3->second->createComponents();
}
......@@ -1019,7 +1059,7 @@ bool VsRegistry::registerComponentInfo(const std::string& componentName,
VsLog::debugLog() <<"ERROR VsH5Reader::registerComponentInfo() - " <<componentName <<" is already registered to component " <<temp <<" index " <<tempIndex <<std::endl;
return false;
} else {
VsLog::debugLog() <<"VsH5Reader::registerComponentInfo() - recieved duplicate registration for " <<varName <<" and index " <<componentNumber <<std::endl;
VsLog::debugLog() <<"VsH5Reader::registerComponentInfo() - received duplicate registration for " <<varName <<" and index " <<componentNumber <<std::endl;
VsLog::debugLog() <<"VsH5Reader::registerComponentInfo() - but all info matches, so it should be ok" <<std::endl;
return true;
}
......
......@@ -113,6 +113,10 @@ public:
int numMDVariables();
VsVariable* findSubordinateMDVar(const std::string& name);
//Transformed meshes
void buildTransformedMeshes();
void buildTransformedVariables();
//VsVars
void buildExpressions(VsH5Group* group);
void addExpression(const std::string& name, const std::string& value);
......
......@@ -42,8 +42,13 @@ std::string VsSchema::compMinorCKey = "compMinorC"; //default ordering
std::string VsSchema::compMajorFKey = "compMajorF"; //currently not supported
std::string VsSchema::compMinorFKey = "compMinorF"; //supported
// Meshes
// Transforms
std::string VsSchema::transformKey = "vsTransform";
std::string VsSchema::transformedMeshKey = "vsTransformedMesh";
std::string VsSchema::zrphiTransformKey = "cylindricalZRPhi";
std::string VsSchema::zrphiTransformKey_deprecated = "Cylindrical";
// Meshes
std::string VsSchema::structuredMeshKey = "structured";
std::string VsSchema::Rectilinear::key = "rectilinear";
......@@ -53,9 +58,6 @@ std::string VsSchema::Rectilinear::axis1Key = "vsAxis1";
std::string VsSchema::Rectilinear::axis1DefaultName = "axis1";
std::string VsSchema::Rectilinear::axis2Key = "vsAxis2";
std::string VsSchema::Rectilinear::axis2DefaultName = "axis2";
std::string VsSchema::Rectilinear::transformKey = "vsTransform";
std::string VsSchema::Rectilinear::transformedMeshKey = "vsTransformedMesh";
std::string VsSchema::Rectilinear::zrphiTransformKey = "cylindricalZRPhi";
std::string VsSchema::Uniform::key = "uniform";
std::string VsSchema::Uniform::key_deprecated = "uniformCartesian";
......
......@@ -46,7 +46,13 @@ struct VsSchema {
static std::string compMinorCKey;
static std::string compMajorFKey;
static std::string compMinorFKey;
// Transforms
static std::string transformKey;
static std::string transformedMeshKey;
static std::string zrphiTransformKey;
static std::string zrphiTransformKey_deprecated;
struct Uniform {
static std::string key;
static std::string key_deprecated;
......@@ -71,11 +77,6 @@ struct VsSchema {
static std::string axis2Key;
static std::string axis2DefaultName;
static std::string transformKey;
static std::string transformedMeshKey;
static std::string zrphiTransformKey;
};
struct Unstructured {
......
......@@ -77,6 +77,10 @@ VsMesh* VsVariable::getMesh() {
return meshMeta;
}
bool VsVariable::hasTransform() {
return meshMeta && meshMeta->hasTransform();
}
// Get hdf5 type
hid_t VsVariable::getType() {
return dataset->getType();
......@@ -101,6 +105,11 @@ std::string VsVariable::getPath() {
return dataset->getPath();
}
// Get transformed name
std::string VsVariable::getFullTransformedName() {
return getFullName() + "_transform";
}
// Get full name
std::string VsVariable::getFullName() {
return dataset->getFullName();
......@@ -348,18 +357,38 @@ dimwarn:
}
void VsVariable::createTransformedVariable() {
VsLog::debugLog() <<"VsVariable::createTransformedVariable() - Creating transformed var name." <<std::endl;
// Does this variable have a transformation?
bool hasTransform = getMesh() && getMesh()->hasTransform();
if (hasTransform) {
VsLog::debugLog()<<"VsVariable::createTransformedVariable() - registering transformed variable: " + getFullTransformedName() <<std::endl;
registry->registerTransformedVarName(getFullTransformedName(), getFullName());
}
VsLog::debugLog() <<"VsVariable::createTransformedVariable() - returning." <<std::endl;
}
void VsVariable::createComponents() {
//Name & register components
VsLog::debugLog() <<"VsVariable::createComponents() - Creating component names." <<std::endl;
// Number of component of the var
size_t numComps = getNumComps();
// Does this variable have a transformation?
bool transformExists = this->hasTransform();
//Note that single-component variables just use the base variable name
//I.E. instead of a singleton named "var_0", we just call it "var"
if (numComps > 1) {
for (size_t i = 0; i < numComps; ++i) {
registry->registerComponent(getFullName(), i, getLabel(i));
if (transformExists) {
registry->registerComponent(getFullTransformedName(), i, getLabel(i));
}
}
}
}
......
......@@ -38,6 +38,9 @@ public:
std::string getMeshName();
VsMesh* getMesh();
/** Does this variable have a transformed version? */
bool hasTransform();
/** Get hdf5 type */
hid_t getType();
......@@ -73,6 +76,11 @@ public:
/** Public method to initialize object.
* Returns NULL on error.*/
static VsVariable* buildObject(VsH5Dataset* dataset);
/** Get the transformed name */
std::string getFullTransformedName();
void createTransformedVariable();
void createComponents();
size_t getNumComps();
......
......@@ -50,6 +50,74 @@ bool VsVariableWithMesh::isCompMajor() {
(indexOrder == VsSchema::compMajorFKey));
}
std::string VsVariableWithMesh::getFullTransformedName() {
return getFullName() + "_transform";
}
bool VsVariableWithMesh::hasTransform() {
return (!getTransformName().empty());
}
std::string VsVariableWithMesh::getTransformName() {
//Look for the vsTransform attribute
//and either retrieve the value or leave the name empty
std::string transformName;
VsH5Attribute* transformNameAtt = getAttribute(VsSchema::transformKey);
if (transformNameAtt) {
transformNameAtt->getStringValue(&transformName);
}
//Make sure this is a recognized value
//All other methods use the return value of this method as a go/no-go test
//So this is the best place to catch bad values
if ((transformName != VsSchema::zrphiTransformKey) &&
(transformName != VsSchema::zrphiTransformKey_deprecated)) {
VsLog::errorLog() <<"VsVariableWithMesh::getTransformName() - Unrecognized value for key "
<< VsSchema::transformKey << " - " <<transformName <<std::endl;
transformName = "";
}
return transformName;
}
std::string VsVariableWithMesh::getTransformedMeshName() {
//Look for the vsTransformName key
std::string transformedMeshName;
VsH5Attribute* transformedMeshNameAtt = getAttribute(VsSchema::transformedMeshKey);
if (transformedMeshNameAtt) {
transformedMeshNameAtt->getStringValue(&transformedMeshName);
if (!transformedMeshName.empty()) {
//We want to make the tranformed mesh appear at the same file level
//as the original mesh.
//So, when we calculate the canonical name, use the PATH, not the FULL NAME
transformedMeshName = makeCanonicalName(getPath(), transformedMeshName);
}
}
// if we didn't find a user supplied name, create a name
if (transformedMeshName.empty()) {
transformedMeshName = getFullName() + "_transform";
transformedMeshName = makeCanonicalName(transformedMeshName);
}
return transformedMeshName;
}
void VsVariableWithMesh::createTransformedVariableAndMesh() {
VsLog::debugLog() <<"VsVariableWithMesh::createTransformedVariableAndMesh() - Creating transformed var name." <<std::endl;
// Does this variable have a transformation?
if (hasTransform()) {
VsLog::debugLog()<<"VsVariableWithMesh::createTransformedVariableAndMesh() - registering transformed variable: " + getFullTransformedName() <<std::endl;
registry->registerTransformedVarName(getFullTransformedName(), getFullName());
//And register the transformed mesh name to match
registry->registerTransformedMeshName(getFullTransformedName(), getFullName());
}
VsLog::debugLog() <<"VsVariableWithMesh::createTransformedVariable() - returning." <<std::endl;
}
// Get dims
std::vector<int> VsVariableWithMesh::getDims()
{
......@@ -316,8 +384,14 @@ void VsVariableWithMesh::createComponents() {
size_t numComps = getNumComps();
//We should only create component names if we have more than one component
//But i'm going to leave it as-is for now...
bool transformExists = hasTransform();
for (size_t i = 0; i < numComps; ++i) {
registry->registerComponent(getFullName(), i, getLabel(i));
if (transformExists) {
registry->registerComponent(getFullTransformedName(), i, getLabel(i));
}
}
VsLog::debugLog() << __CLASS__ << __FUNCTION__ << " " << __LINE__ << " "
......
......@@ -35,7 +35,16 @@ public:
/** Retrieve the entire list of spatial indices */
std::vector<int> getSpatialIndices();
/** Handles tranformation attributes for the "mesh" part of this object */
virtual bool hasTransform();
std::string getTransformName();
std::string getTransformedMeshName();
/** Handles transformation attributes for the "variable" part of this object */
std::string getFullTransformedName();
void createTransformedVariableAndMesh();
/** Supply debugging output */
void write();
......
This diff is collapsed.
......@@ -204,7 +204,7 @@ class avtVsFileFormat: public avtSTMDFileFormat {
vtkDataSet* getRectilinearMesh(VsRectilinearMesh*, bool, int*, int*, int*, bool);
vtkDataSet* getStructuredMesh(VsStructuredMesh*, bool, int*, int*, int*);
vtkDataSet* getUnstructuredMesh(VsUnstructuredMesh*, bool, int*, int*, int*);
vtkDataSet* getPointMesh(VsVariableWithMesh*, bool, int*, int*, int*);
vtkDataSet* getPointMesh(VsVariableWithMesh*, bool, int*, int*, int*, bool);
vtkDataSet* getCurve(int domain, const std::string& name);
/**
......
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