Пример #1
0
        public void WriteTest()
        {
            var objs = CreateMesh();

            using (var mphtxtStream = File.OpenWrite(Path.GetTempFileName()))
                using (var writer = new MphtxtWriter(mphtxtStream))
                {
                    writer.Write(objs);
                }
        }
Пример #2
0
        public void RoundtripTest()
        {
            var mphtxtStream = new MemoryStream();

            using var writer = new MphtxtWriter(mphtxtStream);

            Dictionary <string, MphtxtObject> objs = CreateMesh();

            writer.Write(objs);

            mphtxtStream.Seek(0, SeekOrigin.Begin);
            using var reader = new MphtxtReader(mphtxtStream);
            reader.Read();
        }
Пример #3
0
        public void GlobalSetup()
        {
            mphtxtStream     = new MemoryStream();
            using var writer = new MphtxtWriter(mphtxtStream, true);

            const int pointCount = 1000000;
            const int tetCount   = 500000;

            var coordinates = new CoordinateCollection(3, pointCount);
            var random      = new Random(8269684);

            for (int i = 0; i < pointCount; ++i)
            {
                coordinates[i][0] = random.NextDouble();
                coordinates[i][1] = random.NextDouble();
                coordinates[i][2] = random.NextDouble();
            }

            var tets = new GeometryElementCollection(tetCount, 4);

            for (int i = 0; i < tetCount; ++i)
            {
                tets[i][0]          = random.Next(pointCount);
                tets[i][1]          = random.Next(pointCount);
                tets[i][2]          = random.Next(pointCount);
                tets[i][3]          = random.Next(pointCount);
                tets[i].EntityIndex = 1;
            }

            var mesh = new MphtxtMesh();

            mesh.Coordinates     = coordinates;
            mesh.Elements["tet"] = tets;

            var objs = new Dictionary <string, MphtxtObject>();

            objs["mesh1"] = mesh;

            writer.Write(objs);
        }