private void UpdateUI() { var dataSource = DataSource; if (dataSource == null) { return; } int sectionCount = SectionCount; double sectionHeight = SectionHeight; // one noize for all slices int[] noize = ImageHelper.CreateWhiteNoizeImage(dataSource.Width, dataSource.Depth); Task.Factory.StartNew(() => { for (int iy = 0; iy < sectionCount; iy++) { double y = sectionHeight * iy / (double)sectionCount; var sectionDataSource = dataSource.CreateSectionXZ(y); Dispatcher.BeginInvoke(() => { VectorFieldConvolutionChart chart = new VectorFieldConvolutionChart { DataSource = sectionDataSource, WhiteNoize = noize }; chart.AddHandler(BackgroundRenderer.RenderingFinished, new RoutedEventHandler(OnRenderingFinished)); Material material = new DiffuseMaterial(new ImageBrush(chart.Image.Source)); Billboard billboard = new Billboard { LowerLeft = new Point3D(-1, y, -1), LowerRight = new Point3D(1, y, -1), UpperLeft = new Point3D(-1, y, 1), UpperRight = new Point3D(1, y, 1), Material = material, BackMaterial = material }; billboards.Add(billboard); Children.Add(billboard); }, DispatcherPriority.Background); } }); }
private void UpdateUI() { var dataSource = DataSource; if (dataSource == null) return; int sectionCount = SectionCount; double sectionHeight = SectionHeight; // one noize for all slices int[] noize = ImageHelper.CreateWhiteNoizeImage(dataSource.Width, dataSource.Depth); Task.Factory.StartNew(() => { for (int iy = 0; iy < sectionCount; iy++) { double y = sectionHeight * iy / (double)sectionCount; var sectionDataSource = dataSource.CreateSectionXZ(y); Dispatcher.BeginInvoke(() => { VectorFieldConvolutionChart chart = new VectorFieldConvolutionChart { DataSource = sectionDataSource, WhiteNoize = noize }; chart.AddHandler(BackgroundRenderer.RenderingFinished, new RoutedEventHandler(OnRenderingFinished)); Material material = new DiffuseMaterial(new ImageBrush(chart.Image.Source)); Billboard billboard = new Billboard { LowerLeft = new Point3D(-1, y, -1), LowerRight = new Point3D(1, y, -1), UpperLeft = new Point3D(-1, y, 1), UpperRight = new Point3D(1, y, 1), Material = material, BackMaterial = material }; billboards.Add(billboard); Children.Add(billboard); }, DispatcherPriority.Background); } }); }