Updates will be applied April 15th at 12pm EDT (UTC-0400). GitLab could be a little slow between 12 - 12:45pm EDT.

Commit d48fe2e6 authored by apletzer's avatar apletzer

updating VizSchema version.

 ~ methods now enforce constness
 + support for edge and face data


git-svn-id: http://visit.ilight.com/svn/visit/trunk/src@22709 18c085ea-50e0-402c-830e-de6fd14e8384
parent 54796cf9
...@@ -18,12 +18,6 @@ ${COMMON_SOURCES} ...@@ -18,12 +18,6 @@ ${COMMON_SOURCES}
avtVsFileFormat.C avtVsFileFormat.C
avtVsOptions.C avtVsOptions.C
VsFilter.C VsFilter.C
VsH5Attribute.C
VsH5Dataset.C
VsH5File.C
VsH5Group.C
VsH5Object.C
VsH5Reader.C
VsLog.C VsLog.C
VsMDMesh.C VsMDMesh.C
VsMDVariable.C VsMDVariable.C
...@@ -38,6 +32,13 @@ VsVariable.C ...@@ -38,6 +32,13 @@ VsVariable.C
VsVariableWithMesh.C VsVariableWithMesh.C
VsRegistry.C VsRegistry.C
VsRegistryObject.C VsRegistryObject.C
VsGroup.C
VsObject.C
VsDataset.C
VsAttribute.C
VsFile.C
VsReader.C
VsStaggeredField.C
) )
SET(LIBE_SOURCES SET(LIBE_SOURCES
...@@ -46,12 +47,6 @@ ${COMMON_SOURCES} ...@@ -46,12 +47,6 @@ ${COMMON_SOURCES}
avtVsFileFormat.C avtVsFileFormat.C
avtVsOptions.C avtVsOptions.C
VsFilter.C VsFilter.C
VsH5Attribute.C
VsH5Dataset.C
VsH5File.C
VsH5Group.C
VsH5Object.C
VsH5Reader.C
VsLog.C VsLog.C
VsMDMesh.C VsMDMesh.C
VsMDVariable.C VsMDVariable.C
...@@ -66,6 +61,12 @@ VsVariable.C ...@@ -66,6 +61,12 @@ VsVariable.C
VsVariableWithMesh.C VsVariableWithMesh.C
VsRegistry.C VsRegistry.C
VsRegistryObject.C VsRegistryObject.C
VsGroup.C
VsObject.C
VsDataset.C
VsAttribute.C
VsFile.C
VsReader.C
) )
INCLUDE_DIRECTORIES( INCLUDE_DIRECTORIES(
......
/*
* Main header file for VsApi
*
*
* $Id: $
*/
#include <VsAttribute.h>
#include <VsDataset.h>
#include <VsFile.h>
#include <VsFilter.h>
#include <VsGroup.h>
#include <VsLog.h>
#include <VsMDMesh.h>
#include <VsMDVariable.h>
#include <VsMesh.h>
#include <VsObject.h>
#include <VsReader.h>
#include <VsRectilinearMesh.h>
#include <VsRegistry.h>
#include <VsRegistryObject.h>
#include <VsSchema.h>
#include <VsStructuredMesh.h>
#include <VsUniformMesh.h>
#include <VsUnstructuredMesh.h>
#include <VsUtils.h>
#include <VsVariable.h>
#include <VsVariableWithMesh.h>
/* /*
* VsH5Attribute.cpp * VsAttribute.cpp
* *
* Created on: Apr 28, 2010 * Created on: Apr 28, 2010
* Author: mdurant * Author: mdurant
*/ */
#include "VsH5Attribute.h" #include "VsAttribute.h"
#include "VsLog.h" #include "VsLog.h"
#include <hdf5.h> #include <hdf5.h>
VsH5Attribute::VsH5Attribute(VsH5Object* parentObject, std::string attName, hid_t id): VsAttribute::VsAttribute(VsObject* parentObject, std::string attName, hid_t id):
VsH5Object(parentObject->registry, parentObject, attName, id) { VsObject(parentObject->registry, parentObject, attName, id) {
dataType = H5Aget_type(id); dataType = H5Aget_type(id);
} }
VsH5Attribute::~VsH5Attribute() { VsAttribute::~VsAttribute() {
hid_t id = getId(); hid_t id = getId();
if (id != -1) { if (id != -1) {
H5Aclose(id); H5Aclose(id);
...@@ -23,7 +23,7 @@ VsH5Attribute::~VsH5Attribute() { ...@@ -23,7 +23,7 @@ VsH5Attribute::~VsH5Attribute() {
} }
} }
void VsH5Attribute::write() { void VsAttribute::write() const {
std::string offset = ""; std::string offset = "";
for (int i = 0; i < getDepth(); ++i) { for (int i = 0; i < getDepth(); ++i) {
offset += " "; offset += " ";
...@@ -33,7 +33,7 @@ void VsH5Attribute::write() { ...@@ -33,7 +33,7 @@ void VsH5Attribute::write() {
} }
// Total length // Total length
size_t VsH5Attribute::getLength() { size_t VsAttribute::getLength() const {
size_t len = 1; size_t len = 1;
for (size_t i = 0; i < dims.size(); ++i) { for (size_t i = 0; i < dims.size(); ++i) {
len *= dims[i]; len *= dims[i];
...@@ -41,14 +41,14 @@ size_t VsH5Attribute::getLength() { ...@@ -41,14 +41,14 @@ size_t VsH5Attribute::getLength() {
return len; return len;
} }
herr_t VsH5Attribute::getStringValue(std::string* val) { int VsAttribute::getStringValue(std::string* val) {
hid_t atype = H5Aget_type(getId()); hid_t atype = H5Aget_type(getId());
H5T_class_t type = H5Tget_class(atype); H5T_class_t type = H5Tget_class(atype);
hid_t aspace = H5Aget_space(getId()); hid_t aspace = H5Aget_space(getId());
size_t rank = H5Sget_simple_extent_ndims(aspace); size_t rank = H5Sget_simple_extent_ndims(aspace);
if (type != H5T_STRING) { if (type != H5T_STRING) {
VsLog::warningLog() <<"VsH5Attribute::getStringValue() - Requested attribute " <<getShortName() VsLog::warningLog() <<"VsAttribute::getStringValue() - Requested attribute " <<getShortName()
<<" is not a string value." <<std::endl; <<" is not a string value." <<std::endl;
val->clear(); val->clear();
return -1; return -1;
...@@ -56,7 +56,7 @@ herr_t VsH5Attribute::getStringValue(std::string* val) { ...@@ -56,7 +56,7 @@ herr_t VsH5Attribute::getStringValue(std::string* val) {
//Yes, this is correct (rank != 0) //Yes, this is correct (rank != 0)
if (rank != 0) { if (rank != 0) {
VsLog::warningLog() <<"VsH5Attribute::getStringValue() - Requested attribute " <<getShortName() VsLog::warningLog() <<"VsAttribute::getStringValue() - Requested attribute " <<getShortName()
<<" is not a string value." <<std::endl; <<" is not a string value." <<std::endl;
val->clear(); val->clear();
return -1; return -1;
...@@ -65,7 +65,7 @@ herr_t VsH5Attribute::getStringValue(std::string* val) { ...@@ -65,7 +65,7 @@ herr_t VsH5Attribute::getStringValue(std::string* val) {
size_t len = H5Aget_storage_size(getId()); size_t len = H5Aget_storage_size(getId());
val->resize(len); val->resize(len);
char* v = new char[len]; char* v = new char[len];
herr_t err = H5Aread(getId(), atype, v); int err = H5Aread(getId(), atype, v);
// JRC: is this right? // JRC: is this right?
// err = H5Aread(id, H5T_NATIVE_CHAR, v); // err = H5Aread(id, H5T_NATIVE_CHAR, v);
for (size_t i = 0; i < len; ++i) { for (size_t i = 0; i < len; ++i) {
...@@ -74,7 +74,7 @@ herr_t VsH5Attribute::getStringValue(std::string* val) { ...@@ -74,7 +74,7 @@ herr_t VsH5Attribute::getStringValue(std::string* val) {
//and uses the 5th character for the null terminator //and uses the 5th character for the null terminator
//In h5dump this shows up as a string "mesh" being declared as 5 characters //In h5dump this shows up as a string "mesh" being declared as 5 characters
//If dumped to a terminal, it prints like so: "mesh^@" //If dumped to a terminal, it prints like so: "mesh^@"
VsLog::warningLog() <<"VsH5Attribute::getStringValue() - Found null char inside string attribute: " <<getFullName() <<std::endl; VsLog::warningLog() <<"VsAttribute::getStringValue() - Found null char inside string attribute: " <<getFullName() <<std::endl;
val->resize(i); val->resize(i);
break; break;
} }
...@@ -86,8 +86,8 @@ herr_t VsH5Attribute::getStringValue(std::string* val) { ...@@ -86,8 +86,8 @@ herr_t VsH5Attribute::getStringValue(std::string* val) {
// JRC: This fat interface may not scale? What about // JRC: This fat interface may not scale? What about
// scalar attributes? // scalar attributes?
herr_t VsH5Attribute::getIntVectorValue(std::vector<int>* ivals) { int VsAttribute::getIntVectorValue(std::vector<int>* ivals) {
herr_t err; int err;
size_t npoints; size_t npoints;
hid_t atype = H5Aget_type(getId()); hid_t atype = H5Aget_type(getId());
H5T_class_t type = H5Tget_class(atype); H5T_class_t type = H5Tget_class(atype);
...@@ -95,7 +95,7 @@ herr_t VsH5Attribute::getIntVectorValue(std::vector<int>* ivals) { ...@@ -95,7 +95,7 @@ herr_t VsH5Attribute::getIntVectorValue(std::vector<int>* ivals) {
size_t rank = H5Sget_simple_extent_ndims(aspace); size_t rank = H5Sget_simple_extent_ndims(aspace);
if (type != H5T_INTEGER) { if (type != H5T_INTEGER) {
VsLog::warningLog() <<"VsH5Attribute::getIntVectorValue() - Requested attribute " <<getShortName() VsLog::warningLog() <<"VsAttribute::getIntVectorValue() - Requested attribute " <<getShortName()
<<" is not an integer vector." <<std::endl; <<" is not an integer vector." <<std::endl;
ivals->resize(0); ivals->resize(0);
return -1; return -1;
...@@ -125,9 +125,9 @@ herr_t VsH5Attribute::getIntVectorValue(std::vector<int>* ivals) { ...@@ -125,9 +125,9 @@ herr_t VsH5Attribute::getIntVectorValue(std::vector<int>* ivals) {
// JRC: This fat interface may not scale? What about // JRC: This fat interface may not scale? What about
// scalar attributes? // scalar attributes?
herr_t VsH5Attribute::getFloatVectorValue(std::vector<float>* fvals) { int VsAttribute::getFloatVectorValue(std::vector<float>* fvals) {
herr_t err = 0; int err = 0;
size_t npoints; size_t npoints;
hid_t atype = H5Aget_type(getId()); hid_t atype = H5Aget_type(getId());
H5T_class_t type = H5Tget_class(atype); H5T_class_t type = H5Tget_class(atype);
...@@ -135,7 +135,7 @@ herr_t VsH5Attribute::getFloatVectorValue(std::vector<float>* fvals) { ...@@ -135,7 +135,7 @@ herr_t VsH5Attribute::getFloatVectorValue(std::vector<float>* fvals) {
size_t rank = H5Sget_simple_extent_ndims(aspace); size_t rank = H5Sget_simple_extent_ndims(aspace);
if (type != H5T_FLOAT) { if (type != H5T_FLOAT) {
VsLog::warningLog() <<"VsH5Attribute::getFloatVectorValue() - Requested attribute " <<getShortName() VsLog::warningLog() <<"VsAttribute::getFloatVectorValue() - Requested attribute " <<getShortName()
<<" is not a floating point vector." <<std::endl; <<" is not a floating point vector." <<std::endl;
fvals->resize(0); fvals->resize(0);
return -1; return -1;
...@@ -164,8 +164,8 @@ herr_t VsH5Attribute::getFloatVectorValue(std::vector<float>* fvals) { ...@@ -164,8 +164,8 @@ herr_t VsH5Attribute::getFloatVectorValue(std::vector<float>* fvals) {
// JRC: This fat interface may not scale? What about // JRC: This fat interface may not scale? What about
// scalar attributes? // scalar attributes?
herr_t VsH5Attribute::getDoubleVectorValue(std::vector<double>* dvals) { int VsAttribute::getDoubleVectorValue(std::vector<double>* dvals) {
herr_t err = 0; int err = 0;
size_t npoints; size_t npoints;
hid_t atype = H5Aget_type(getId()); hid_t atype = H5Aget_type(getId());
H5T_class_t type = H5Tget_class(atype); H5T_class_t type = H5Tget_class(atype);
...@@ -173,7 +173,7 @@ herr_t VsH5Attribute::getDoubleVectorValue(std::vector<double>* dvals) { ...@@ -173,7 +173,7 @@ herr_t VsH5Attribute::getDoubleVectorValue(std::vector<double>* dvals) {
size_t rank = H5Sget_simple_extent_ndims(aspace); size_t rank = H5Sget_simple_extent_ndims(aspace);
if (type != H5T_FLOAT) { if (type != H5T_FLOAT) {
VsLog::warningLog() <<"VsH5Attribute::getDoubleVectorValue() - Requested attribute " <<getShortName() VsLog::warningLog() <<"VsAttribute::getDoubleVectorValue() - Requested attribute " <<getShortName()
<<" is not a floating point vector." <<std::endl; <<" is not a floating point vector." <<std::endl;
dvals->resize(0); dvals->resize(0);
return -1; return -1;
......
/** /**
* @file VsH5Attribute.h * @file VsAttribute.h
* *
* @class VsH5Attribute * @class VsAttribute
* @brief Represents an hdf5 attribute from an hdf5 file. * @brief Represents an hdf5 attribute from an hdf5 file.
* *
* Saves the name and hdf5 id of an attribute. Provides * Saves the name and hdf5 id of an attribute. Provides
...@@ -12,33 +12,33 @@ ...@@ -12,33 +12,33 @@
* Author: mdurant * Author: mdurant
*/ */
#ifndef VSH5ATTRIBUTE_H_ #ifndef VS_ATTRIBUTE_H_
#define VSH5ATTRIBUTE_H_ #define VS_ATTRIBUTE_H_
#include "VsH5Object.h" #include "VsObject.h"
#include <vector> #include <vector>
#include <string> #include <string>
#include <map> #include <map>
class VsH5Attribute: public VsH5Object { class VsAttribute: public VsObject {
public: public:
VsH5Attribute(VsH5Object* parentObject, std::string attName, hid_t id); VsAttribute(VsObject* parentObject, std::string attName, hid_t id);
virtual ~VsH5Attribute(); virtual ~VsAttribute();
void write(); void write() const;
hid_t getType() { return dataType; } hid_t getType() const { return dataType; }
size_t getLength(); size_t getLength() const;
// Get the value of this attribute // Get the value of this attribute
// CAUTION: Calling the incorrect accessor will result in invalid or null data // CAUTION: Calling the incorrect accessor will result in invalid or null data
herr_t getStringValue(std::string* val); int getStringValue(std::string* val);
herr_t getIntVectorValue(std::vector<int>* ivals); int getIntVectorValue(std::vector<int>* ivals);
herr_t getFloatVectorValue(std::vector<float>* fvals); int getFloatVectorValue(std::vector<float>* fvals);
herr_t getDoubleVectorValue(std::vector<double>* dvals); int getDoubleVectorValue(std::vector<double>* dvals);
private: private:
hid_t dataType; hid_t dataType;
std::vector<int> dims; std::vector<int> dims;
}; };
#endif /* VSH5ATTRIBUTE_H_ */ #endif /* VS_ATTRIBUTE_H_ */
/* /*
* VsH5Dataset.cpp * VsDataset.cpp
* *
* Created on: Apr 27, 2010 * Created on: Apr 27, 2010
* Author: mdurant * Author: mdurant
*/ */
#include "VsH5Dataset.h" #include "VsDataset.h"
#include "VsH5Attribute.h" #include "VsAttribute.h"
#include "VsLog.h" #include "VsLog.h"
#include "VsSchema.h" #include "VsSchema.h"
#include <iostream> #include <iostream>
...@@ -19,8 +19,9 @@ ...@@ -19,8 +19,9 @@
#include "VsVariable.h" #include "VsVariable.h"
#include "VsVariableWithMesh.h" #include "VsVariableWithMesh.h"
VsH5Dataset::VsH5Dataset(VsRegistry* r, VsH5Object* parentObject, std::string datasetName, hid_t id): VsDataset::VsDataset(VsRegistry* r, VsObject* parentObject,
VsH5Object(r, parentObject, datasetName, id){ const std::string& datasetName, hid_t id):
VsObject(r, parentObject, datasetName, id){
dataType = H5Tget_native_type(H5Dget_type(id), H5T_DIR_DEFAULT); dataType = H5Tget_native_type(H5Dget_type(id), H5T_DIR_DEFAULT);
loadDims(); loadDims();
...@@ -28,7 +29,7 @@ VsH5Dataset::VsH5Dataset(VsRegistry* r, VsH5Object* parentObject, std::string da ...@@ -28,7 +29,7 @@ VsH5Dataset::VsH5Dataset(VsRegistry* r, VsH5Object* parentObject, std::string da
registry->add(this); registry->add(this);
} }
VsH5Dataset::~VsH5Dataset() { VsDataset::~VsDataset() {
hid_t id = this->getId(); hid_t id = this->getId();
if (id != -1) { if (id != -1) {
H5Dclose(id); H5Dclose(id);
...@@ -40,7 +41,7 @@ VsH5Dataset::~VsH5Dataset() { ...@@ -40,7 +41,7 @@ VsH5Dataset::~VsH5Dataset() {
// Total length // Total length
size_t VsH5Dataset::getLength() { size_t VsDataset::getLength() const {
size_t len = 1; size_t len = 1;
for (size_t i = 0; i < dims.size(); ++i) { for (size_t i = 0; i < dims.size(); ++i) {
len *= dims[i]; len *= dims[i];
...@@ -48,12 +49,12 @@ size_t VsH5Dataset::getLength() { ...@@ -48,12 +49,12 @@ size_t VsH5Dataset::getLength() {
return len; return len;
} }
void VsH5Dataset::loadDims() { void VsDataset::loadDims() {
hid_t space = H5Dget_space(getId()); hid_t space = H5Dget_space(getId());
size_t rank = H5Sget_simple_extent_ndims(space); size_t rank = H5Sget_simple_extent_ndims(space);
if (rank <= 0) { if (rank <= 0) {
VsLog::errorLog() <<"VsH5Dataset::loadDims() - Rank was <= 0 for dataset: " <<getFullName() <<std::endl; VsLog::errorLog() <<"VsDataset::loadDims() - Rank was <= 0 for dataset: " << getFullName() <<std::endl;
return; return;
} }
std::vector<hsize_t> sdim(rank); std::vector<hsize_t> sdim(rank);
...@@ -64,15 +65,14 @@ void VsH5Dataset::loadDims() { ...@@ -64,15 +65,14 @@ void VsH5Dataset::loadDims() {
} }
} }
std::vector<int> VsH5Dataset::getDims() { std::vector<int> VsDataset::getDims() const {
return dims; return dims;
} }
void VsH5Dataset::write() { void VsDataset::write() const {
std::string offset = ""; std::string offset = "";
for (int i = 0; i < getDepth(); ++i) { for (int i = 0; i < getDepth(); ++i) {
offset += " "; offset += " ";
} }
VsLog::debugLog() << offset << getFullName() <<"(" <<getId() <<")" << std::endl;
VsLog::debugLog() << offset<<getFullName() <<"(" <<getId() <<")" <<std::endl;
} }
/**
* @file VsDataset.h
*
* @class VsDataset
* @brief Represents a dataset stored in an hdf5 file.
*
* Provides accessors to retrieve attributes and data from
* an hdf5 file.
*
* Created on: Apr 27, 2010
* Author: mdurant
*/
#ifndef VS_DATASET_H_
#define VS_DATASET_H_
#include <string>
#include "VsObject.h"
#include <hdf5.h>
#include <vector>
#include <map>
class VsAttribute;
class VsDataset : public VsObject {
public:
/**
* Constructor
*/
VsDataset(VsRegistry* r, VsObject* parentObject,
const std::string& datasetName, hid_t id);
/**
* Destructor
*/
virtual ~VsDataset();
/**
* Write debug information to log file
*/
void write() const;
/**
* Get the total number of data values
* @return number
*/
size_t getLength() const;
/**
* Get the dimensions
* @return number of values along each axis
*/
std::vector<int> getDims() const;
/**
* Get the number of dimensions (rank)
* @return number
*/
size_t getNumDims() const { return this->dims.size(); }
/**
* Get the hdf5 type
* @return type
*/
hid_t getType() const { return this->dataType; }
private:
std::vector<int> dims;
hid_t dataType;
std::vector<VsAttribute*> attributes;
void loadDims();
};
#endif /* VS_DATASET_H_ */
/* /*
* VsH5File.cpp * VsFile.cpp
* *
* Created on: Apr 27, 2010 * Created on: Apr 27, 2010
* Author: mdurant * Author: mdurant
*/ */
#include "VsH5File.h" #include "VsFile.h"
#include "VsLog.h" #include "VsLog.h"
#include "VsFilter.h"
#include "hdf5.h" #include "hdf5.h"
#include "visit-hdf5.h" #include "VsDataset.h"
#include "VsH5Dataset.h" #include "VsGroup.h"
#include "VsH5Group.h"
#include "VsVariable.h" #include "VsVariable.h"
#include "VsVariableWithMesh.h" #include "VsVariableWithMesh.h"
#include "VsRectilinearMesh.h" #include "VsRectilinearMesh.h"
#include "VsUniformMesh.h" #include "VsUniformMesh.h"
#include "VsUnstructuredMesh.h"