void MainWindow_Loaded(object sender, RoutedEventArgs e)
        {
            tabControl.SelectionChanged += new SelectionChangedEventHandler(tabControl_SelectionChanged);

            PotentialField3D field = new PotentialField3D();

            field.AddPotentialPoint(new Point3D(0.5, 0.5, 0.5), 2);
            field.AddPotentialPoint(new Point3D(0.2, 0.2, 0.5), -3);
            field.AddPotentialPoint(new Point3D(0.8, 0.2, 0.9), 10);
            field.AddPotentialPoint(new Point3D(0.3, 0.7, 0.1), 5);

            PotentialFieldChart3D fieldChart = new PotentialFieldChart3D {
                Field = field
            };

            viewport.Children.Insert(0, fieldChart);

            dataSource3D = VectorField3D.CreateTangentPotentialField(field, 200, 200, 200);

            //dataSource3D = VectorField3D.CreatePotentialField(200, 200, 200,
            //    new PotentialPoint3D(new Point3D(0.5, 0.5, 0.5), 2), new PotentialPoint3D(new Point3D(0.2, 0.2, 0.5), -1));

            DataContext           = dataSource3D;
            isoSurface.DataSource = dataSource3D.GetMagnitudeDataSource();


            //var spiralDS = VectorField3D.CreateSpiral(
            //    latticeX: 10, latticeY: 20, latticeZ: 3,
            //    width: 2, height: 2, depth: 1).TransformGrid(transform);

            var filteredDataSource = dataSource3D.Filter(20, 20, 20);

            //vectorChart3D.DataSource = filteredDataSource;
            //gridChart.GridSource = filteredDataSource;

            //timer.Start();

            plotterXY.DataContext = dataSource3D.CreateSectionXY(0.0);
            plotterXZ.DataContext = dataSource3D.CreateSectionXZ(0.0);
            plotterYZ.DataContext = dataSource3D.CreateSectionYZ(0.0);

            sectionChartX.ThirdCoordinate = 0.0001;
            sectionChartY.ThirdCoordinate = 0.0001;
            sectionChartZ.ThirdCoordinate = 0.0001;
            sectionChartX.UpdateUI();
            sectionChartY.UpdateUI();
            sectionChartZ.UpdateUI();

            mainTabControl.SelectedIndex = 3;
            convolutionStack.DataSource  = dataSource3D;

            UpdateSelectedTab();

            progressBar.SetBinding(ProgressBar.ValueProperty, new Binding("RenderingProgress")
            {
                Source = convolutionStack
            });
        }
		private void MainWindow_Loaded(object sender, RoutedEventArgs e)
		{
			PotentialField3D field = new PotentialField3D();
			field.AddPotentialPoint(new Point3D(0.5, 0.5, 0.5), 2);
			field.AddPotentialPoint(new Point3D(0.2, 0.2, 0.5), -3);
			field.AddPotentialPoint(new Point3D(0.8, 0.2, 0.9), 10);
			field.AddPotentialPoint(new Point3D(0.3, 0.7, 0.1), 5);

			dataSource3D = VectorField3D.CreateTangentPotentialField(field, 200, 200, 200);

			plotterXY.DataContext = dataSource3D.CreateSectionXY(0.0);
			plotterXZ.DataContext = dataSource3D.CreateSectionXZ(0.0);
			plotterYZ.DataContext = dataSource3D.CreateSectionYZ(0.0);
		}
		void MainWindow_Loaded(object sender, RoutedEventArgs e)
		{
			tabControl.SelectionChanged += new SelectionChangedEventHandler(tabControl_SelectionChanged);

			PotentialField3D field = new PotentialField3D();
			field.AddPotentialPoint(new Point3D(0.5, 0.5, 0.5), 2);
			field.AddPotentialPoint(new Point3D(0.2, 0.2, 0.5), -3);
			field.AddPotentialPoint(new Point3D(0.8, 0.2, 0.9), 10);
			field.AddPotentialPoint(new Point3D(0.3, 0.7, 0.1), 5);

			PotentialFieldChart3D fieldChart = new PotentialFieldChart3D { Field = field };
			viewport.Children.Insert(0, fieldChart);

			dataSource3D = VectorField3D.CreateTangentPotentialField(field, 200, 200, 200);

			//dataSource3D = VectorField3D.CreatePotentialField(200, 200, 200,
			//    new PotentialPoint3D(new Point3D(0.5, 0.5, 0.5), 2), new PotentialPoint3D(new Point3D(0.2, 0.2, 0.5), -1));

			DataContext = dataSource3D;
			isoSurface.DataSource = dataSource3D.GetMagnitudeDataSource();


			//var spiralDS = VectorField3D.CreateSpiral(
			//    latticeX: 10, latticeY: 20, latticeZ: 3,
			//    width: 2, height: 2, depth: 1).TransformGrid(transform);

			var filteredDataSource = dataSource3D.Filter(20, 20, 20);
			//vectorChart3D.DataSource = filteredDataSource;
			//gridChart.GridSource = filteredDataSource;

			//timer.Start();

			plotterXY.DataContext = dataSource3D.CreateSectionXY(0.0);
			plotterXZ.DataContext = dataSource3D.CreateSectionXZ(0.0);
			plotterYZ.DataContext = dataSource3D.CreateSectionYZ(0.0);

			sectionChartX.ThirdCoordinate = 0.0001;
			sectionChartY.ThirdCoordinate = 0.0001;
			sectionChartZ.ThirdCoordinate = 0.0001;
			sectionChartX.UpdateUI();
			sectionChartY.UpdateUI();
			sectionChartZ.UpdateUI();

			mainTabControl.SelectedIndex = 3;
			convolutionStack.DataSource = dataSource3D;

			UpdateSelectedTab();

			progressBar.SetBinding(ProgressBar.ValueProperty, new Binding("RenderingProgress") { Source = convolutionStack });
		}
		private IDataSource2D<Vector> CreateSection(IUniformDataSource3D<Vector3D> dataSource, double ratio)
		{
			switch (Variable)
			{
				case SectionVariable.X:
					return dataSource.CreateSectionYZ(ratio);
				case SectionVariable.Y:
					return dataSource.CreateSectionXZ(ratio);
				case SectionVariable.Z:
					return dataSource.CreateSectionXY(ratio);
				default:
					throw new NotImplementedException();
			}
		}
        private void MainWindow_Loaded(object sender, RoutedEventArgs e)
        {
            PotentialField3D field = new PotentialField3D();

            field.AddPotentialPoint(new Point3D(0.5, 0.5, 0.5), 2);
            field.AddPotentialPoint(new Point3D(0.2, 0.2, 0.5), -3);
            field.AddPotentialPoint(new Point3D(0.8, 0.2, 0.9), 10);
            field.AddPotentialPoint(new Point3D(0.3, 0.7, 0.1), 5);

            dataSource3D = VectorField3D.CreateTangentPotentialField(field, 200, 200, 200);

            plotterXY.DataContext = dataSource3D.CreateSectionXY(0.0);
            plotterXZ.DataContext = dataSource3D.CreateSectionXZ(0.0);
            plotterYZ.DataContext = dataSource3D.CreateSectionYZ(0.0);
        }
        private IDataSource2D <Vector> CreateSection(IUniformDataSource3D <Vector3D> dataSource, double ratio)
        {
            switch (Variable)
            {
            case SectionVariable.X:
                return(dataSource.CreateSectionYZ(ratio));

            case SectionVariable.Y:
                return(dataSource.CreateSectionXZ(ratio));

            case SectionVariable.Z:
                return(dataSource.CreateSectionXY(ratio));

            default:
                throw new NotImplementedException();
            }
        }
Example #7
0
        public static IDataSource2D <Vector> CreateSectionYZ(this IUniformDataSource3D <Vector3D> dataSource, double ratio)
        {
            if (dataSource == null)
            {
                throw new ArgumentNullException("dataSource");
            }
            if (ratio < 0 || ratio > 1)
            {
                throw new IndexOutOfRangeException("ratio should be in [0..1].");
            }

            int x0 = (int)Math.Floor(dataSource.Width * ratio);
            int x1 = Math.Min(x0 + 1, dataSource.Width - 1);

            double xRatio = dataSource.Width * ratio - x0;

            if (xRatio < 0 || xRatio > 1)
            {
                throw new ArgumentOutOfRangeException();
            }

            int height = dataSource.Height;
            int depth  = dataSource.Depth;
            var data   = dataSource.Data;

            Vector[,] dataArray = new Vector[height, depth];

            for (int iy = 0; iy < height; iy++)
            {
                for (int iz = 0; iz < depth; iz++)
                {
                    Vector3D vec3D = data[x0, iy, iz] * (1 - xRatio) + data[x1, iy, iz] * xRatio;
                    dataArray[iy, iz] = new Vector(vec3D.Y, vec3D.Z);
                }
            }

            NonUniformDataSource2D <Vector> result = new NonUniformDataSource2D <Vector>(dataSource.YCoordinates, dataSource.ZCoordinates, dataArray);

            return(result);
        }
Example #8
0
        public static IDataSource2D <Vector> CreateSectionXZ(this IUniformDataSource3D <Vector3D> dataSource, double ratio)
        {
            if (dataSource == null)
            {
                throw new ArgumentNullException("dataSource");
            }
            if (ratio < 0 || ratio > 1)
            {
                throw new IndexOutOfRangeException("ratio should be in [0..1].");
            }

            int y0 = (int)Math.Floor(dataSource.Height * ratio);
            int y1 = Math.Min(y0 + 1, dataSource.Height - 1);

            double yRatio = dataSource.Depth * ratio - y0;

            if (yRatio < 0 || yRatio > 1)
            {
                throw new ArgumentOutOfRangeException();
            }

            int width = dataSource.Width;
            int depth = dataSource.Depth;
            var data  = dataSource.Data;

            Vector[,] dataArray = new Vector[width, depth];

            for (int ix = 0; ix < width; ix++)
            {
                for (int iz = 0; iz < depth; iz++)
                {
                    Vector3D vec3D = data[ix, y0, iz] * (1 - yRatio) + data[ix, y1, iz] * yRatio;
                    dataArray[ix, iz] = new Vector(vec3D.X, vec3D.Z);
                }
            }

            NonUniformDataSource2D <Vector> result = new NonUniformDataSource2D <Vector>(dataSource.XCoordinates, dataSource.ZCoordinates, dataArray);

            return(result);
        }
Example #9
0
        public static IDataSource2D <Vector> CreateSectionXY(this IUniformDataSource3D <Vector3D> dataSource, double ratio)
        {
            if (dataSource == null)
            {
                throw new ArgumentNullException("dataSource");
            }
            if (ratio < 0 || ratio > 1)
            {
                throw new IndexOutOfRangeException("ratio should be in [0..1].");
            }

            int z0 = (int)Math.Floor(dataSource.Depth * ratio);
            int z1 = Math.Min(z0 + 1, dataSource.Depth - 1);

            double zRatio = dataSource.Depth * ratio - z0;

            if (zRatio < 0 || zRatio > 1)
            {
                throw new ArgumentOutOfRangeException();
            }

            int width  = dataSource.Width;
            int height = dataSource.Height;
            var data   = dataSource.Data;

            Vector[,] dataArray = new Vector[width, height];

            for (int ix = 0; ix < width; ix++)
            {
                for (int iy = 0; iy < height; iy++)
                {
                    Vector3D vec3D = data[ix, iy, z0] * (1 - zRatio) + data[ix, iy, z1] * zRatio;
                    dataArray[ix, iy] = new Vector(vec3D.X, vec3D.Y);
                }
            }

            NonUniformDataSource2D <Vector> result = new NonUniformDataSource2D <Vector>(dataSource.XCoordinates, dataSource.YCoordinates, dataArray);

            return(result);
        }