public override object Read(string path)
        {
            var obj = new RefineMeshDictData();
            string txt;
            using (var reader = new StreamReader(path))
            {
                txt = reader.ReadToEnd();
            }
            var grammar = new OpenFoamGrammar();
            var parser = new Parser(grammar);
            var tree = parser.Parse(txt);

            foreach (ParseTreeNode rootEntryNode in tree.Root.FindDictEntries(null))
            {
                var identifier = rootEntryNode.GetEntryIdentifier();
                string patch;
                switch ( identifier )
                {
                    case "set":
                        obj.setvalue = rootEntryNode.GetBasicValString();
                        break;
                    case "coordinateSystem":
                        obj.coordsys = rootEntryNode.GetBasicValEnum<CoordinateSystem>();
                        break;
                    case "globalCoeffs":
                        {
                            var dict = rootEntryNode.GetDictContent();
                            obj.globalCoeffs = GetCoeffs(ref dict, out patch);
                        }
                        break;
                    case "patchLocalCoeffs":
                        {
                            var dict = rootEntryNode.GetDictContent();
                            obj.patchLocalCoeffs = GetCoeffs(ref dict, out patch);
                            obj.patch = patch;
                        }
                        break;
                    case "directions":
                        {
                            obj.direction = new List<DirectionType>();
                            var s = rootEntryNode.ChildNodes[2].ChildNodes[1].GetArrayOfString();
                            foreach (string t in s)
                            {
                                obj.direction.Add(t.ToEnum<DirectionType>());
                            }
                        }
                        break;
                    case "useHexTopology":
                        obj.useHexTopology = rootEntryNode.GetBasicValBool();
                        break;
                    case "geometricCut":
                        obj.geometricCut = rootEntryNode.GetBasicValBool();
                        break;
                    case "writeMesh":
                        obj.writeMesh = rootEntryNode.GetBasicValBool();
                        break;
                }
            }
            return obj;
        }
Exemplo n.º 2
0
        public override object Read(string path)
        {
            var    obj = new RefineMeshDictData();
            string txt;

            using (var reader = new StreamReader(path))
            {
                txt = reader.ReadToEnd();
            }
            var grammar = new OpenFoamGrammar();
            var parser  = new Parser(grammar);
            var tree    = parser.Parse(txt);

            foreach (ParseTreeNode rootEntryNode in tree.Root.FindDictEntries(null))
            {
                var    identifier = rootEntryNode.GetEntryIdentifier();
                string patch;
                switch (identifier)
                {
                case "set":
                    obj.setvalue = rootEntryNode.GetBasicValString();
                    break;

                case "coordinateSystem":
                    obj.coordsys = rootEntryNode.GetBasicValEnum <CoordinateSystem>();
                    break;

                case "globalCoeffs":
                {
                    var dict = rootEntryNode.GetDictContent();
                    obj.globalCoeffs = GetCoeffs(ref dict, out patch);
                }
                break;

                case "patchLocalCoeffs":
                {
                    var dict = rootEntryNode.GetDictContent();
                    obj.patchLocalCoeffs = GetCoeffs(ref dict, out patch);
                    obj.patch            = patch;
                }
                break;

                case "directions":
                {
                    obj.direction = new List <DirectionType>();
                    var s = rootEntryNode.ChildNodes[2].ChildNodes[1].GetArrayOfString();
                    foreach (string t in s)
                    {
                        obj.direction.Add(t.ToEnum <DirectionType>());
                    }
                }
                break;

                case "useHexTopology":
                    obj.useHexTopology = rootEntryNode.GetBasicValBool();
                    break;

                case "geometricCut":
                    obj.geometricCut = rootEntryNode.GetBasicValBool();
                    break;

                case "writeMesh":
                    obj.writeMesh = rootEntryNode.GetBasicValBool();
                    break;
                }
            }
            return(obj);
        }