Commit 3e5ede6a authored by cyrush's avatar cyrush

merge 2.8RC fixes for mfem db plugin

git-svn-id: http://visit.ilight.com/svn/visit/trunk/src@24579 18c085ea-50e0-402c-830e-de6fd14e8384
parent 4b4d2c11
......@@ -47,6 +47,8 @@
#include "JSONRoot.h"
#include <StringHelpers.h>
#include <iostream>
using namespace std;
......@@ -89,15 +91,32 @@ JSONRootPath::~JSONRootPath()
// Programmer: Cyrus Harrison
// Creation: Thu Jun 12 16:02:35 PDT 2014
//
// Modifications:
// Cyrus Harrison, Tue Sep 23 14:42:52 PDT 2014
// Added support for simple domain expansion.
//
// ****************************************************************************
std::string
JSONRootPath::Expand(int domain) const
{
//
// TODO: handle domain id mapping (likley printf style expansion)
// Note: This currenlty only handles "%05d" as the format string.
//
return path;
std::size_t path_pattern = path.find("%05d");
if(path_pattern != std::string::npos)
{
char buff[64];
SNPRINTF(buff,64,"%05d",domain);
return StringHelpers::Replace(path,
"%05d",
std::string(buff));
}
else
{
return path;
}
}
// ****************************************************************************
......@@ -444,6 +463,10 @@ JSONRoot::NumberOfDataSets() const
// Programmer: Cyrus Harrison
// Creation: Thu Jun 12 16:02:35 PDT 2014
//
// Modifications:
// Cyrus Harrison, Wed Sep 24 10:47:00 PDT 2014
// Handle abs path logic.
//
// ****************************************************************************
void
JSONRoot::ParseJSON(const std::string &json_root)
......@@ -451,9 +474,12 @@ JSONRoot::ParseJSON(const std::string &json_root)
// clear existing structure
dsets.clear();
std::string root_file = StringHelpers::Absname(".",json_root);
std::string root_dir = StringHelpers::Dirname(root_file);
// open root file and read its contents
ifstream iroot;
iroot.open(json_root.c_str());
iroot.open(root_file.c_str());
std::string json((std::istreambuf_iterator<char>(iroot)),
std::istreambuf_iterator<char>());
......@@ -479,7 +505,8 @@ JSONRoot::ParseJSON(const std::string &json_root)
const rapidjson::Value &json_dset = dsets_itr->value;
// handle # of domains, meshes w/ tags
curr_dset.SetNumberOfDomains(json_dset["domains"].GetInt());
curr_dset.Mesh().Path().Set(json_dset["mesh"]["path"].GetString());
std::string mesh_file_path = json_dset["mesh"]["path"].GetString();
curr_dset.Mesh().Path().Set(ResolveAbsolutePath(root_dir,mesh_file_path));
if(json_dset["mesh"].HasMember("tags"))
{
const rapidjson::Value &mesh_tags = json_dset["mesh"]["tags"];
......@@ -499,7 +526,8 @@ JSONRoot::ParseJSON(const std::string &json_root)
const rapidjson::Value &json_field = fields_itr->value;
string curr_field_name = fields_itr->name.GetString();
JSONRootEntry &curr_field = curr_dset.Field(curr_field_name);
curr_field.Path().Set(json_field["path"].GetString());
std::string field_file_path = json_field["path"].GetString();
curr_field.Path().Set(ResolveAbsolutePath(root_dir,field_file_path));
const rapidjson::Value &json_tags = json_field["tags"];
for (rapidjson::Value::ConstMemberIterator tags_itr = json_tags.MemberBegin();
tags_itr != json_tags.MemberEnd(); ++tags_itr)
......@@ -513,6 +541,23 @@ JSONRoot::ParseJSON(const std::string &json_root)
}
}
// ****************************************************************************
// Method: JSONRoot::ResolveAbsolutePath
//
// Purpose: Helper for abs path logicl.
//
//
// Programmer: Cyrus Harrison
// Creation: Wed Sep 24 10:47:00 PDT 2014
//
// ****************************************************************************
std::string
JSONRoot::ResolveAbsolutePath(const std::string &root_dir,
const std::string &file_path)
{
return StringHelpers::Absname(root_dir,file_path);
}
// ****************************************************************************
// Method: JSONRoot::ToJson
//
......
......@@ -65,7 +65,7 @@ class JSONRootPath
virtual ~JSONRootPath();
std::string Expand(int domain=0) const;
std::string Get() const { return path;}
void Set(const std::string &path);
private:
......@@ -144,6 +144,10 @@ class JSONRootDataSet
// Programmer: Cyrus Harrison
// Creation: Thu Jun 12 16:02:35 PDT 2014
//
// Modifications:
// Cyrus Harrison, Wed Sep 24 10:47:00 PDT 2014
// Added helper for abs path logic.
//
// ****************************************************************************
class JSONRoot
{
......@@ -162,7 +166,7 @@ public:
private:
void ParseJSON(const std::string &json_root);
std::string ResolveAbsolutePath(const std::string &root_dir,const std::string &file_path);
std::map<std::string,JSONRootDataSet> dsets;
......
This diff is collapsed.
......@@ -61,6 +61,10 @@ class JSONRoot;
// Programmer: harrison37 -- generated by xml2avt
// Creation: Fri May 23 15:16:20 PST 2014
//
// Modifications:
// Cyrus Harrison, Wed Sep 24 10:47:00 PDT 2014
// Enable time varying metadata and SIL.
//
// ****************************************************************************
class avtMFEMFileFormat : public avtSTMDFileFormat
......@@ -84,9 +88,12 @@ class avtMFEMFileFormat : public avtSTMDFileFormat
virtual vtkDataArray *GetVar(int, const char *);
virtual vtkDataArray *GetVectorVar(int, const char *);
virtual void ActivateTimestep(void);
protected:
virtual void PopulateDatabaseMetaData(avtDatabaseMetaData *);
bool HasInvariantMetaData(void) const { return false; };
bool HasInvariantSIL(void) const { return false; };
private:
int selectedLOD;
......
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