Exemplo n.º 1
0
        private void OpenFile(object sender, RoutedEventArgs e)
        {
            OpenFileDialog openfile = new OpenFileDialog();

            openfile.Filter =
                "3D models (*.off; *.dcel)|*.off;*.dcel|" +
                "Object File Format files (*.off)|*.off|" +
                "DCEL serialized objects (*.dcel)|*.dcel";

            // Show open file dialog box
            Nullable <bool> result = openfile.ShowDialog();

            // Process open file dialog box results
            if (result == true)
            {
                string filename = openfile.FileName;

                if (filename != null && File.Exists(filename))
                {
                    SW = File.AppendText(@"viewer.log");
                    string ext = System.IO.Path.GetExtension(filename);

                    if (ext == ".off")
                    {
                        sw.Restart();
                        mesh = DCELTools.LoadFromOFF(filename);
                        sw.Stop();
                        SW.WriteLine("Dcel loading from off: " + sw.Elapsed.TotalMilliseconds);
                        SW.Close();
                        Create3dMesh();
                    }
                    if (ext == ".dcel")
                    {
                        sw.Restart();
                        mesh = DCELTools.DeserializeMesh(filename);
                        sw.Stop();
                        SW.WriteLine("Dcel loading from object: " + sw.Elapsed.TotalMilliseconds);
                        SW.Close();
                        Create3dMesh();
                    }
                    if (wfCheck.IsChecked)
                    {
                        wfCheck.IsChecked = false;
                    }
                    MeshInfo();
                }
                else
                {
                    MessageBox.Show("Errore durante l'apertura del file", "Errore!", MessageBoxButton.OK, MessageBoxImage.Warning);
                }
            }
        }
Exemplo n.º 2
0
        public MainWindow()
        {
            InitializeComponent();

            SW.WriteLine("#Log");

            sw.Start();
            mesh = DCELTools.LoadFromOFF(@"shapes/cube.off");
            sw.Stop();
            SW.WriteLine("Dcel loading from off: " + sw.Elapsed.TotalMilliseconds);
            SW.Close();

            Create3dMesh();
            MeshInfo();
        }