void Apply(SurfacePlotModel model) { var nx = model.Nx; var ny = model.Ny; var surface = new UniformSurfaceChart3D(); _3dChart = surface; _3dChart.SetDataNo(nx * ny); surface.SetGrid(nx, ny); _wireframes.Thickness = model.Data.Thickness; _wireframes.Color = model.Data.Color.Convert(); var x = model.Data.Xs; var y = model.Data.Ys; var z = model.Data.Zs; var length = x.Length; for (var i = 0; i < length; i++) { _3dChart[i] = new Vertex3D { X = (Single)x[i], Y = (Single)y[i], Z = (Single)z[i] }; } SetView(model.XAxis, model.YAxis, model.ZAxis); SetColors(model.ZAxis, model.Colors); var meshs = ((UniformSurfaceChart3D)_3dChart).GetMeshes(); var backMaterial = new DiffuseMaterial(new SolidColorBrush(Colors.Gray)); _model3d.UpdateModel(meshs, backMaterial); Project(model.XAxis, model.YAxis, model.ZAxis); TransformChart(); if (model.IsWireframeShown) { _wireframes.MakeWireframe(_model3d.Content); } else { _wireframes.Points.Clear(); } if (!model.IsSurfaceShown) { MainViewport.Children.Remove(_model3d); } else if (!MainViewport.Children.Contains(_model3d)) { MainViewport.Children.Add(_model3d); } if (IsAxisShown) { ShowAxis(); } }
public void Redraw() { SurfacePlotModel mySurfacePlotModel = new SurfacePlotModel(); mySurfacePlotView.DataContext = mySurfacePlotModel; if (Data != null) { //Convert list of states double[] xArray = new double[Data.Count]; double[] tArray = new double[Data.Count]; double[,] yArray = new double[Data.Count, Data.Count]; for (int i = 0; i < Data.Count; i++) { xArray[i] = Data[i].sensor.X; tArray[i] = Data[i].sensor.T; for (int j = 0; j < Data.Count; j++) { if (i == j) { yArray[i, j] = Data[i].Y; } else { yArray[i, j] = 0; } } } //draw mySurfacePlotModel.PlotData(yArray, xArray, tArray); } }
public MeshView(pr_G29T_MeshMap mm) { InitializeComponent(); _mm = mm; // Initialize surface plot objects viewModel = new SurfacePlotModel(); surfacePlotView.DataContext = viewModel; //surfacePlotView.SurfaceBrush = BrushHelper.CreateGradientBrush(Colors.Red, Colors.Green, Colors.Blue); viewModel.PlotData(_mm.MeshValues); viewModel.ShowMiniCoordinates = true; viewModel.ShowSurfaceMesh = false; //UpdateMesh3DView(); }