protected override async Task ImportData() { FLogger.Log(LogType.Message, "ChunkImporter: Importing Data"); IOMessages.CurrentState = "Importing Data"; try { using (var stream = new FileStream(FilePath, FileMode.Open, FileAccess.Read, FileShare.Read, DefaultBufferSize, DefaultFileOptions)) using (var reader = new StreamReader(stream)) { string line; Char delimiter = ' '; while ((line = await reader.ReadLineAsync()) != null) { if (line.Length > 0 && LinesProcessed >= skipLines) { String[] lineStrings = line.Split(delimiter); if (lineStrings[0] == "v") { ParticleData particleData = new ParticleData(); Triple <int, int, int> chunkId = new Triple <int, int, int>(); chunkId.x = 0; chunkId.y = 0; chunkId.z = 0; if (DataStructure.ContainsKey("x")) { Single x = Single.Parse(lineStrings[DataStructure["x"] + 1], CultureInfo.InvariantCulture); x += (Single)Offsets.x; x *= (Single)ScaleValue; particleData.x = x; chunkId.x = Convert.ToInt32(Math.Floor((x - BoundsMin.x) / ChunkSize.x)); if (chunkId.x < 0) { chunkId.x = 0; } if (chunkId.x >= ChunkCount.x) { chunkId.x = ChunkCount.x - 1; } } if (DataStructure.ContainsKey("y")) { Single y = Single.Parse(lineStrings[DataStructure["y"] + 1], CultureInfo.InvariantCulture); y += (Single)Offsets.y; y *= (Single)ScaleValue; particleData.y = y; chunkId.y = Convert.ToInt32(Math.Floor((y - BoundsMin.y) / ChunkSize.y)); if (chunkId.y < 0) { chunkId.y = 0; } if (chunkId.y >= ChunkCount.y) { chunkId.y = ChunkCount.y - 1; } } if (DataStructure.ContainsKey("z")) { Single z = Single.Parse(lineStrings[DataStructure["z"] + 1], CultureInfo.InvariantCulture); z += (Single)Offsets.z; z *= (Single)ScaleValue; particleData.z = z; chunkId.z = Convert.ToInt32(Math.Floor((z - BoundsMin.z) / ChunkSize.z)); if (chunkId.z < 0) { chunkId.z = 0; } if (chunkId.z >= ChunkCount.z) { chunkId.z = ChunkCount.z - 1; } } int chunkIndex = chunkId.x + chunkId.y * ChunkCount.x + chunkId.z * ChunkCount.x * ChunkCount.y; if (chunkIndex > 0 && chunkIndex < _chunkManager.ChunkList.Count) { Chunk chunk = _chunkManager.ChunkList[chunkIndex]; chunk.BinaryWriter.Write(particleData.GetByteArray()); chunk.UpdateElementCount(); } LinesProcessed++; // update count of processed lines -> needed to calculate progress if (LinesProcessed == Lines) { break; // all vertices are parsed now -> break } } } } _chunkManager.UpdateElementCount(); IOMessages.CurrentState = "Finished"; } } catch (Exception e) { FLogger.Log(LogType.Error, e.ToString()); IOMessages.CurrentState = e.ToString(); } }