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);
                }
            }
        }
        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();
        }
        public DCELPrimitive(GraphicsDevice graphicsDevice, DCELMesh mesh, float size)
        {
            int n = 0;

            mesh.Triangulate();

            foreach (var face in mesh.FaceList)
            {
                DCELHalfEdge he    = face.Edge;
                DCELVertex   first = he.Origin;

                do
                {
                    AddVertex(
                        GetVector3(he.Origin.Coordinates) * size,
                        GetVector3(he.Origin.Normal));
                    AddIndex(n++);
                    he = he.Next;
                }while (he.Origin != first);
            }

            InitializePrimitive(graphicsDevice);
        }