Commit 437f952c authored by Moritz's avatar Moritz

VTKDataReader: added reading of sclaar data (only one scalar value for now)

parent f2cf4524
......@@ -7,6 +7,7 @@ using UnityEngine;
namespace Teamproject {
public class VTKDataReader {
public Dictionary<int, PCachePoint> points { get; private set; }
public Dictionary<int, float> pressure { get; private set; }
private string _pathToFolder;
private string _filenames;
......@@ -128,12 +129,45 @@ namespace Teamproject {
currentLine = reader.ReadLine();
}
//TODO: rename to "read scalar data", change to reading multiple parameters
private void ReadPressure() {
currentLine = reader.ReadLine();
if (!currentLine.StartsWith("SCALARS"))
return;
string lookuptable = reader.ReadLine();
//go into the first line with scalar values
currentLine = reader.ReadLine();
int currentPointID = 0;
int maxPointID = points.Keys.Count - 1;
pressure = new Dictionary<int, float>();
while(currentPointID != maxPointID) {
if (currentLine.EndsWith(" "))
currentLine = currentLine.Remove(currentLine.Length - 1); //else we get an empty array entry at the end in the next line
string[] parts = currentLine.Split(' ');
foreach (string part in parts) {
float f;
if(float.TryParse(part.Split('.')[0], out f)) {
} else {
Debug.Log("Failed parsing value >" + part + "<");
f = 0;
}
pressure[currentPointID] = f;
currentPointID++;
}
currentLine = reader.ReadLine();
}
//TODO: read scalar info
}
......
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