Beispiel #1
0
        VrmLib.Model ReadModel(string path)
        {
            var bytes = MigrationVrm.Migrate(File.ReadAllBytes(path));

            var data = new GlbLowLevelParser(path, bytes).Parse();

            var model = ModelReader.Read(data);

            return(model);
        }
Beispiel #2
0
        VrmLib.Model ReadModel(string path)
        {
            var bytes = MigrationVrm.Migrate(File.ReadAllBytes(path));

            var parser = new GltfParser();

            parser.Parse("migrated", bytes);

            var model = ModelReader.Read(parser);

            return(model);
        }
        public void Generate()
        {
            var mapper = Substitute.For <IMapper <IModelGenerator> >();

            mapper.ContainsKey("NPN", false).Returns(true);

            IModelGenerator value;

            mapper.TryGetValue("NPN", false, out value).Returns(
                x =>
            {
                x[2] = null;
                return(true);
            });

            var readingContext = Substitute.For <ICircuitContext>();

            readingContext.NameGenerator.GenerateObjectName(Arg.Any <string>()).Returns(x => x[0].ToString());
            readingContext.CaseSensitivity.Returns(new SpiceNetlistCaseSensitivitySettings());

            var resultService = Substitute.For <IResultService>();

            readingContext.Result.Returns(resultService);
            var modelsGenerator = Substitute.For <IModelsGenerator>();

            modelsGenerator.GenerateModel(
                Arg.Any <IModelGenerator>(),
                Arg.Any <string>(),
                Arg.Any <string>(),
                Arg.Any <string>(),
                Arg.Any <ParameterCollection>(),
                Arg.Any <ICircuitContext>()).Returns(x => new BipolarJunctionTransistorModel((string)x[1]));

            // act
            ModelReader reader = new ModelReader(mapper, modelsGenerator);
            var         model  = new Models.Netlist.Spice.Objects.Model("2Na2222", new ParameterCollection(new List <Parameter>()
            {
                new BracketParameter()
                {
                    Name = "NPN"
                }
            }), null);

            reader.Read(model, readingContext);

            // assert
            modelsGenerator.Received().GenerateModel(Arg.Any <IModelGenerator>(), Arg.Any <string>(), "2Na2222", "NPN", Arg.Any <ParameterCollection>(), Arg.Any <ICircuitContext>());
            resultService.Received().AddEntity(Arg.Is <Entity>((Entity e) => e.Name == "2Na2222"));
        }
        protected override void LoadFile(HpiArchive archive, HpiArchive.FileInfo file)
        {
            var records = this.objectMap[HpiPath.GetFileNameWithoutExtension(file.Name)];

            var fileBuffer = new byte[file.Size];

            archive.Extract(file, fileBuffer);

            using (var b = new MemoryStream(fileBuffer))
            {
                var adapter = new ModelEdgeReaderAdapter();
                var reader  = new ModelReader(b, adapter);
                reader.Read();
                var wire = Util.RenderWireframe(adapter.Edges);
                foreach (var record in records)
                {
                    this.Records.Add(new KeyValuePair <string, OffsetBitmap>(record.Name, wire));
                }
            }
        }
        private void LoadModelData(string modelFile)
        {
            _Model = ModelReader.Read(modelFile);

            if (_Model != null)
            {
                _Model.Name = Path.GetFileNameWithoutExtension(Model.FileNames.First());

                textBoxModelName.Text = _Model.Name;

                labelModelType.Text = Model.Type.ToString();

                labelModelNumberOfModels.Text = Model.NumberOfModels.ToString();

                labelModelDateMin.Text = Model.MinDate.ToDateTime().ToShortDateString();

                labelModelDateMax.Text = Model.MaxDate.ToDateTime().ToShortDateString();
            }
            else
            {
                MessageBox.Show(this, "", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Beispiel #6
0
        private void OpenToolStripMenuItemClick(object sender, EventArgs e)
        {
            var dlg = new OpenFileDialog();

            dlg.Filter = "3do Files|*.3do|All Files|*.*";
            var result = dlg.ShowDialog(this);

            if (result == DialogResult.OK)
            {
                var path = dlg.FileName;

                var adapter = new ModelEdgeReaderAdapter();

                using (var s = File.OpenRead(path))
                {
                    var loader = new ModelReader(s, adapter);
                    loader.Read();
                }

                var bmp = Util.RenderWireframe(adapter.Edges);

                this.pictureBox1.Image = bmp.Bitmap;
            }
        }