public void graficaBlender() { Model3DGroup caras = new Model3DGroup(); LeerArchivo archivo = null; Point3D[] puntosArchvivo = null; int numCaras = 0; int numPuntos = 0; var ofd = new Microsoft.Win32.OpenFileDialog(); var result = ofd.ShowDialog(); if (result == false) { return; } archivo = new LeerArchivo(ofd.FileName); numCaras = archivo.numLines(); for (int indiceLinea = 0; indiceLinea < numCaras; indiceLinea++) { string[] puntosCadena = archivo.getLine(indiceLinea + 1).Split(' '); numPuntos = puntosCadena.Count() / 3; //Dispatcher.Invoke(DispatcherPriority.Normal, new Action(() => this.Consola.Text = this.Consola.Text + numPuntos + "------" + indiceLinea + " de " + numCaras + '\n')); //Verificacion de que las coordenadas vengan en tercias if ((numPuntos % 3) == 0) { puntosArchvivo = new Point3D[numPuntos]; int i = 0; for (int indicePunto = 0; indicePunto < numPuntos; indicePunto++) { double x = Convert.ToDouble(puntosCadena.ElementAt(i++)); double y = Convert.ToDouble(puntosCadena.ElementAt(i++)); double z = Convert.ToDouble(puntosCadena.ElementAt(i++)); puntosArchvivo[indicePunto] = new Point3D(x, y, z); //Dispatcher.Invoke(DispatcherPriority.Normal, new Action(() => this.Consola.Text = Consola.Text = this.Consola.Text + " X=" + puntosArchvivo[indicePunto].X + " Y=" + puntosArchvivo[indicePunto].Y + " Z=" + puntosArchvivo[indicePunto].Z + '\n')); } caras.Children.Add(graficos.CreatePolygonModel(puntosArchvivo)); puntos = puntosArchvivo; } } model = new ModelVisual3D(); model.Content = caras; if (model != null) { /*if (!Application.Current.Dispatcher.CheckAccess()) * { * Application.Current.Dispatcher.Invoke(new MyFunctionDelegate(MyFunction)); * return; // Important to leave the culprit thread * }*/ //Dispatcher.Invoke(DispatcherPriority.Normal, new Action(() => this.mainViewport.Children.Add(model))); //addChildrenViwePort(model); this.mainViewport.Children.Add(model); } }
private void Button_Click_3(object sender, RoutedEventArgs e) { string textoLinea = archivo.getLine(Convert.ToInt32(numLinea.Text)); if (textoLinea != null) { cajaTexto.Text = textoLinea; } else { cajaTexto.Text = "Linea no encontrada"; } }
public void graficaBlender() { Model3DGroup caras = new Model3DGroup(); LeerArchivo archivo = null; Point3D[] puntosArchvivo = null; int numCaras = 0; int numPuntos = 0; var ofd = new Microsoft.Win32.OpenFileDialog(); var result = ofd.ShowDialog(); if (result == false) return; archivo = new LeerArchivo(ofd.FileName); numCaras = archivo.numLines(); for (int indiceLinea = 0; indiceLinea < numCaras; indiceLinea++) { string[] puntosCadena = archivo.getLine(indiceLinea + 1).Split(' '); numPuntos = puntosCadena.Count() / 3; //Dispatcher.Invoke(DispatcherPriority.Normal, new Action(() => this.Consola.Text = this.Consola.Text + numPuntos + "------" + indiceLinea + " de " + numCaras + '\n')); //Verificacion de que las coordenadas vengan en tercias if ((numPuntos % 3) == 0) { puntosArchvivo = new Point3D[numPuntos]; int i = 0; for (int indicePunto = 0; indicePunto < numPuntos; indicePunto++) { double x = Convert.ToDouble(puntosCadena.ElementAt(i++)); double y = Convert.ToDouble(puntosCadena.ElementAt(i++)); double z = Convert.ToDouble(puntosCadena.ElementAt(i++)); puntosArchvivo[indicePunto] = new Point3D(x, y, z); //Dispatcher.Invoke(DispatcherPriority.Normal, new Action(() => this.Consola.Text = Consola.Text = this.Consola.Text + " X=" + puntosArchvivo[indicePunto].X + " Y=" + puntosArchvivo[indicePunto].Y + " Z=" + puntosArchvivo[indicePunto].Z + '\n')); } caras.Children.Add(graficos.CreatePolygonModel(puntosArchvivo)); puntos = puntosArchvivo; } } model = new ModelVisual3D(); model.Content = caras; if (model != null) { /*if (!Application.Current.Dispatcher.CheckAccess()) { Application.Current.Dispatcher.Invoke(new MyFunctionDelegate(MyFunction)); return; // Important to leave the culprit thread }*/ //Dispatcher.Invoke(DispatcherPriority.Normal, new Action(() => this.mainViewport.Children.Add(model))); //addChildrenViwePort(model); this.mainViewport.Children.Add(model); } }