Esempio n. 1
0
        public string[] LoadFile(string patch)
        {
            var lines = File.ReadAllLines(patch);

            lines = _helper.RemoveFromText(lines, "\t");
            return(lines);
        }
Esempio n. 2
0
        List <(Vector, Vector, int)> GetHRange(string[] lines)
        {
            List <(Vector, Vector, int)> list = new List <(Vector, Vector, int)>();
            var text = _helper.RemoveFromText(lines, "{", "}", "Hrange");

            foreach (string line in text)
            {
                if (line != "")
                {
                    if (line != " ")
                    {
                        if (line[0] != '#')
                        {
                            var    data  = line.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries);
                            Vector start = new Vector(double.Parse(data[0]), double.Parse(data[1]), double.Parse(data[2]));
                            Vector end   = new Vector(double.Parse(data[3]), double.Parse(data[4]), double.Parse(data[5]));
                            list.Add((start, end, int.Parse(data[6])));
                        }
                    }
                }
            }
            return(list);
        }
        private IMifVectorField CreateAtlasField(string[] lines)
        {
            string atlas = lines.Where(s => s.Contains("atlas")).FirstOrDefault();
            var atlasIEnumerable = atlas.Select((c, i) => new { c, i }).
                Where((c, i) => i > atlas.IndexOf(':')).Select(s => s.c);
            atlas = string.Concat(atlasIEnumerable).Replace(" ", "");
            string valueVectorString = lines.Where(s => s.Contains("default_value"))
                .FirstOrDefault().Replace("default_value", "");
            Vector vector = CreateVector(valueVectorString);
            int lineNumber = helper.GetIndexOfStringContaining(lines, "values");
            var text = helper.GetCodeToClosingBrace(lines, lineNumber, '{');
            text = helper.RemoveFromText(text, "{", "}");
            var list = new List<(string, Vector)>();
            for (int i = 1; i < text.Length - 1; i++)
            {
                var values = text[i].Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                list.Add((values[0],new Vector(double.Parse(values[1]), double.Parse(values[2]),
                    double.Parse(values[3]))));
            }


            return new AtlasVectorField(new AtlasNameOnly(atlas), vector, list);
        }