Text archives Help
- From: brownlee@sci.utah.edu
- To: manta@sci.utah.edu
- Subject: [Manta] r2216 - in trunk/Model: Materials Readers
- Date: Tue, 22 Apr 2008 13:41:16 -0600 (MDT)
Author: brownlee
Date: Tue Apr 22 13:41:15 2008
New Revision: 2216
Modified:
trunk/Model/Materials/Volume.cc
trunk/Model/Readers/UDAReader.cc
trunk/Model/Readers/UDAReader.h
Log:
fixes for UDAReader
Modified: trunk/Model/Materials/Volume.cc
==============================================================================
--- trunk/Model/Materials/Volume.cc (original)
+++ trunk/Model/Materials/Volume.cc Tue Apr 22 13:41:15 2008
@@ -92,7 +92,7 @@
_slices.push_back(ColorSlice(p*9, RGBAColor(Color(RGB(1, 0.89411765,
0.3137255)), 1)));
_slices.push_back(ColorSlice(p*10, RGBAColor(Color(RGB(1, 0.96862745,
0.47058824)), 1)));
_slices.push_back(ColorSlice(p*11, RGBAColor(Color(RGB(1, 1,
0.70588237)), 1)));
- _slices.push_back(ColorSlice(p*11, RGBAColor(Color(RGB(1, 1, 1)),
1)));
+ _slices.push_back(ColorSlice(p*12, RGBAColor(Color(RGB(1, 1, 1)),
1)));
break;
}
case GreyScale:
Modified: trunk/Model/Readers/UDAReader.cc
==============================================================================
--- trunk/Model/Readers/UDAReader.cc (original)
+++ trunk/Model/Readers/UDAReader.cc Tue Apr 22 13:41:15 2008
@@ -7,12 +7,15 @@
using namespace std;
using namespace Manta;
-void parseTimestepFile(string);
-void parseDataFile(string filename);
-void parseLevel(xmlDocPtr doc, xmlNodePtr cur, UDAReader::Timestep&
timestep);
-void parsePatch(xmlDocPtr doc, xmlNodePtr cur, UDAReader::Timestep&
timestep);
+static void parseLevel(xmlDocPtr doc, xmlNodePtr cur, UDAReader::Timestep&
timestep);
+static void parsePatch(xmlDocPtr doc, xmlNodePtr cur, UDAReader::Timestep&
timestep);
-string parseXMLString(string st)
+static string parseDirectory(string file)
+{
+ return file.substr(0,file.find_last_of("/")+1);
+}
+
+static string parseXMLString(string st)
{
for (unsigned int i=0;i<st.length();i++)
{
@@ -28,6 +31,7 @@
assert(directory.length());
if (directory[directory.length()-1] != '/')
directory = directory + string("/");
+ _directory = directory;
filename = directory + string("index.xml");
cout << "UDAReader, reading: " << filename << endl;
xmlDocPtr doc;
@@ -58,7 +62,7 @@
{
if ((!xmlStrcmp(t->name, (const xmlChar*)"timestep")))
{
- parseTimestepFile((const char*)xmlGetProp(t,(const
xmlChar*)"href"));
+ parseTimestepFile(string(_directory+string((const
char*)xmlGetProp(t,(const xmlChar*)"href"))));
}
t = t->next;
}
@@ -68,9 +72,10 @@
xmlFreeDoc(doc);
}
- void parseTimestepFile(string filename)
+ void UDAReader::parseTimestepFile(string filename)
{
UDAReader::Timestep timestep;
+ timestep.dir = parseDirectory(filename);
cout << "Parsing Timestep: " << filename << "\n";
xmlDocPtr doc;
xmlNodePtr cur;
@@ -110,9 +115,9 @@
xmlNodePtr t = cur->xmlChildrenNode;
while (t != NULL)
{
- if ((!xmlStrcmp(t->name, (const xmlChar*)"datafile")))
+ if ((!xmlStrcmp(t->name, (const xmlChar*)"Datafile")))
{
- parseDataFile((const char*)xmlGetProp(t,(const
xmlChar*)"href"));
+ parseDataFile(string(timestep.dir + string((const
char*)xmlGetProp(t,(const xmlChar*)"href"))));
}
t = t->next;
}
@@ -120,9 +125,13 @@
cur = cur->next;
}
xmlFreeDoc(doc);
+ //cout << "parsing timestep done.\n" << "lower: " <<
timestep.lower.x() << " " << timestep.lower.y() << " " << timestep.lower.z()
<< endl;
+ //cout << "upper: " << timestep.upper.x() << " " <<
timestep.upper.y() << " " << timestep.upper.z() << endl;
+ //cout << "indices: " << timestep.indices.x() << " " <<
timestep.indices.y() << " " << timestep.indices.z() << endl;
}
- void parseDataFile(string filename)
+ void UDAReader::parseDataFile(string filename)
{
+ // cout << "parsing datafile: " << filename << endl;
xmlDocPtr doc;
xmlNodePtr cur;
doc = xmlParseFile(filename.c_str());
@@ -157,27 +166,27 @@
if ((!xmlStrcmp(t->name, (const xmlChar*)"index")))
{
stringstream s((const char*)xmlNodeListGetString(doc,
cur->xmlChildrenNode, 1));
- s >> v.index; }
+ s >> v.index;
+ }
+ if ((!xmlStrcmp(t->name, (const xmlChar*)"patch")))
+ {
+ stringstream s((const char*)xmlNodeListGetString(doc,
cur->xmlChildrenNode, 1));
+ s >> v.patchId;
+ }
if ((!xmlStrcmp(t->name, (const xmlChar*)"start")))
{
+ stringstream s((const char*)xmlNodeListGetString(doc,
cur->xmlChildrenNode, 1));
+ s >> v.start;
}
if ((!xmlStrcmp(t->name, (const xmlChar*)"end")))
{
+ stringstream s((const char*)xmlNodeListGetString(doc,
cur->xmlChildrenNode, 1));
+ s >> v.end;
}
if ((!xmlStrcmp(t->name, (const xmlChar*)"filename")))
{
- }
- t = t->next;
- }
- }
- if ((!xmlStrcmp(cur->name, (const xmlChar *)"Data")))
- {
- xmlNodePtr t = cur->xmlChildrenNode;
- while (t != NULL)
- {
- if ((!xmlStrcmp(t->name, (const xmlChar*)"datafile")))
- {
- parseDataFile((const char*)xmlGetProp(t,(const
xmlChar*)"href"));
+ v.filename = string((const
char*)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1));
+ _dataMapping[v.filename].push_back(v);
}
t = t->next;
}
@@ -205,6 +214,7 @@
int x, y, z;
stringstream s(parseXMLString((const
char*)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1)));
s >> x >> y >> z;
+ //TODO: need cellspacing?
}
if ((!xmlStrcmp(cur->name, (const xmlChar *)"Patch")))
{
@@ -215,7 +225,7 @@
}
void parsePatch(xmlDocPtr doc, xmlNodePtr cur, UDAReader::Timestep&
timestep)
{
- cout << "Parsing Patch\n";
+ // cout << "Parsing Patch\n";
UDAReader::Patch patch;
cur = cur->xmlChildrenNode;
while (cur != NULL)
@@ -250,6 +260,9 @@
{
stringstream s(parseXMLString((const
char*)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1)));
s >> patch.highIndex[0] >> patch.highIndex[1] >>
patch.highIndex[2];
+ patch.highIndex[0]++;
+ patch.highIndex[1]++;
+ patch.highIndex[2]++;
timestep.indices[0] =
max(patch.highIndex[0],timestep.indices[0]);
timestep.indices[1] =
max(patch.highIndex[1],timestep.indices[1]);
timestep.indices[2] =
max(patch.highIndex[2],timestep.indices[2]);
Modified: trunk/Model/Readers/UDAReader.h
==============================================================================
--- trunk/Model/Readers/UDAReader.h (original)
+++ trunk/Model/Readers/UDAReader.h Tue Apr 22 13:41:15 2008
@@ -17,7 +17,8 @@
#include <vector>
#include <string>
#include <sstream>
-
+#include <map>
+
namespace Manta
{
@@ -26,13 +27,16 @@
public:
UDAReader() {}
void readUDA(std::string directory);
+ void parseTimestepFile(std::string filename);
+ void parseDataFile(std::string file);
struct Timestep
{
+ std::string dir;
Vector lower, upper, indices;
};
struct VarInfo
{
- std::string name;
+ std::string name, filename;
int start, end, index, patchId, type;
};
struct Patch
@@ -41,6 +45,8 @@
Vector lower, upper, lowIndex, highIndex;
};
private:
+ std::string _directory;
+ std::map <std::string, std::vector<VarInfo> > _dataMapping;
};
}
- [Manta] r2216 - in trunk/Model: Materials Readers, brownlee, 04/22/2008
Archive powered by MHonArc 2.6.16.