private void AddSurface(ChartStyle cs, DataSeriesSurface ds) { Matrix3D m = Utility.AzimuthElevation(cs.Elevation, cs.Azimuth); Polygon plg = new Polygon(); Point3D[,] pts = ds.PointArray; Point3D[,] pts1 = new Point3D[pts.GetLength(0), pts.GetLength(1)]; //double[,] zValues = new double[pts.GetLength(0), pts.GetLength(1)]; double zmin = ds.ZDataMin(); double zmax = ds.ZDataMax(); for (int i = 0; i < pts.GetLength(0); i++) { for (int j = 0; j < pts.GetLength(1); j++) { //zValues[i, j] = pts[i, j].Z; pts1[i, j] = pts[i, j]; pts[i, j] = cs.Normalize3D(m, pts[i, j]); } } // Draw surface chart: if (!IsInterp) { for (int i = 0; i < pts.GetLength(0) - 1; i++) { int ii = i; if (cs.Elevation >= 0) { ii = i; if (cs.Azimuth >= -180 && cs.Azimuth < 0) { ii = pts.GetLength(0) - 2 - i; } } else { ii = pts.GetLength(0) - 2 - i; if (cs.Azimuth >= -180 && cs.Azimuth < 0) { ii = i; } } for (int j = 0; j < pts.GetLength(1) - 1; j++) { int jj = j; if (cs.Elevation < 0) { jj = pts.GetLength(1) - 2 - j; } plg = new Polygon(); plg.Points.Add(new Point(pts[ii, jj].X, pts[ii, jj].Y)); plg.Points.Add(new Point(pts[ii, jj + 1].X, pts[ii, jj + 1].Y)); plg.Points.Add(new Point(pts[ii + 1, jj + 1].X, pts[ii + 1, jj + 1].Y)); plg.Points.Add(new Point(pts[ii + 1, jj].X, pts[ii + 1, jj].Y)); plg.StrokeThickness = ds.LineThickness; plg.Stroke = ds.LineColor; plg.Fill = GetBrush(pts1[ii, jj].Z, zmin, zmax); cs.ChartCanvas.Children.Add(plg); } } if (cs.IsColorBar && IsColormap) { AddColorBar(cs, ds, zmin, zmax); } } else if (IsInterp) { for (int i = 0; i < pts.GetLength(0) - 1; i++) { int ii = i; if (cs.Elevation >= 0) { ii = i; if (cs.Azimuth >= -180 && cs.Azimuth < 0) { ii = pts.GetLength(0) - 2 - i; } } else { ii = pts.GetLength(0) - 2 - i; if (cs.Azimuth >= -180 && cs.Azimuth < 0) { ii = i; } } for (int j = 0; j < pts.GetLength(1) - 1; j++) { int jj = j; if (cs.Elevation < 0) { jj = pts.GetLength(1) - 2 - j; } Point3D[] points = new Point3D[4]; points[0] = pts1[ii, j]; points[1] = pts1[ii, j + 1]; points[2] = pts1[ii + 1, j + 1]; points[3] = pts1[ii + 1, j]; Interp(cs, m, points, zmin, zmax); plg = new Polygon(); plg.Stroke = ds.LineColor; plg.Points.Add(new Point(pts[ii, j].X, pts[ii, j].Y)); plg.Points.Add(new Point(pts[ii, j + 1].X, pts[ii, j + 1].Y)); plg.Points.Add(new Point(pts[ii + 1, j + 1].X, pts[ii + 1, j + 1].Y)); plg.Points.Add(new Point(pts[ii + 1, j].X, pts[ii + 1, j].Y)); //cs.ChartCanvas.Children.Add(plg); } } } if (cs.IsColorBar && IsColormap) { AddColorBar(cs, ds, zmin, zmax); } }
private void AddMeshZ(ChartStyle cs, DataSeriesSurface ds) { Matrix3D m = Utility.AzimuthElevation(cs.Elevation, cs.Azimuth); Polygon plg = new Polygon(); Point3D[,] pts = ds.PointArray; Point3D[,] pts1 = new Point3D[pts.GetLength(0), pts.GetLength(1)]; double[,] zValues = new double[pts.GetLength(0), pts.GetLength(1)]; double zmin = ds.ZDataMin(); double zmax = ds.ZDataMax(); for (int i = 0; i < pts.GetLength(0); i++) { for (int j = 0; j < pts.GetLength(1); j++) { zValues[i, j] = pts[i, j].Z; pts1[i, j] = new Point3D(pts[i, j].X, pts[i, j].Y, pts[i, j].Z); pts[i, j] = cs.Normalize3D(m, pts[i, j]); } } // Draw mesh using the z-order method: for (int i = 0; i < pts.GetLength(0) - 1; i++) { int ii = i; if (cs.Elevation >= 0) { ii = i; if (cs.Azimuth >= -180 && cs.Azimuth < 0) { ii = pts.GetLength(0) - 2 - i; } } else { ii = pts.GetLength(0) - 2 - i; if (cs.Azimuth >= -180 && cs.Azimuth < 0) { ii = i; } } for (int j = 0; j < pts.GetLength(1) - 1; j++) { int jj = j; if (cs.Elevation < 0) { jj = pts.GetLength(1) - 2 - j; } plg = new Polygon(); plg.Points.Add(new Point(pts[ii, jj].X, pts[ii, jj].Y)); plg.Points.Add(new Point(pts[ii, jj + 1].X, pts[ii, jj + 1].Y)); plg.Points.Add(new Point(pts[ii + 1, jj + 1].X, pts[ii + 1, jj + 1].Y)); plg.Points.Add(new Point(pts[ii + 1, jj].X, pts[ii + 1, jj].Y)); plg.Stroke = Brushes.Black; plg.StrokeThickness = ds.LineThickness; plg.Fill = Brushes.White; if (IsHiddenLine) { plg.Fill = Brushes.Transparent; } if (IsColormap) { plg.Stroke = GetBrush(zValues[ii, jj], zmin, zmax); } cs.ChartCanvas.Children.Add(plg); } } //Draw curtain lines: Point3D[] pta = new Point3D[4]; for (int i = 0; i < pts1.GetLength(0); i++) { int jj = pts1.GetLength(0) - 1; if (cs.Elevation >= 0) { if (cs.Azimuth >= -90 && cs.Azimuth <= 90) { jj = 0; } } else if (cs.Elevation < 0) { jj = 0; if (cs.Azimuth >= -90 && cs.Azimuth <= 90) { jj = pts1.GetLength(0) - 1; } } if (i < pts1.GetLength(0) - 1) { pta[0] = new Point3D(pts1[i, jj].X, pts1[i, jj].Y, pts1[i, jj].Z); pta[1] = new Point3D(pts1[i + 1, jj].X, pts1[i + 1, jj].Y, pts1[i + 1, jj].Z); pta[2] = new Point3D(pts1[i + 1, jj].X, pts1[i + 1, jj].Y, cs.Zmin); pta[3] = new Point3D(pts1[i, jj].X, pts1[i, jj].Y, cs.Zmin); for (int k = 0; k < 4; k++) { pta[k] = cs.Normalize3D(m, pta[k]); } plg = new Polygon(); plg.Stroke = Brushes.Black; plg.StrokeThickness = ds.LineThickness; plg.Fill = Brushes.White; plg.Points.Add(new Point(pta[0].X, pta[0].Y)); plg.Points.Add(new Point(pta[1].X, pta[1].Y)); plg.Points.Add(new Point(pta[2].X, pta[2].Y)); plg.Points.Add(new Point(pta[3].X, pta[3].Y)); if (IsHiddenLine) { plg.Fill = Brushes.Transparent; } if (IsColormap) { plg.Stroke = GetBrush(pts1[i, jj].Z, zmin, zmax); } cs.ChartCanvas.Children.Add(plg); } } for (int j = 0; j < pts1.GetLength(1); j++) { int ii = 0; if (cs.Elevation >= 0) { if (cs.Azimuth >= 0 && cs.Azimuth <= 180) { ii = pts1.GetLength(1) - 1; } } else if (cs.Elevation < 0) { if (cs.Azimuth >= -180 && cs.Azimuth <= 0) { ii = pts1.GetLength(1) - 1; } } if (j < pts1.GetLength(1) - 1) { pta[0] = new Point3D(pts1[ii, j].X, pts1[ii, j].Y, pts1[ii, j].Z); pta[1] = new Point3D(pts1[ii, j + 1].X, pts1[ii, j + 1].Y, pts1[ii, j + 1].Z); pta[2] = new Point3D(pts1[ii, j + 1].X, pts1[ii, j + 1].Y, cs.Zmin); pta[3] = new Point3D(pts1[ii, j].X, pts1[ii, j].Y, cs.Zmin); for (int k = 0; k < 4; k++) { pta[k] = cs.Normalize3D(m, pta[k]); } plg = new Polygon(); plg.Stroke = Brushes.Black; plg.StrokeThickness = ds.LineThickness; plg.Fill = Brushes.White; plg.Points.Add(new Point(pta[0].X, pta[0].Y)); plg.Points.Add(new Point(pta[1].X, pta[1].Y)); plg.Points.Add(new Point(pta[2].X, pta[2].Y)); plg.Points.Add(new Point(pta[3].X, pta[3].Y)); if (IsHiddenLine) { plg.Fill = Brushes.Transparent; } if (IsColormap) { plg.Stroke = GetBrush(pts1[ii, j].Z, zmin, zmax); } cs.ChartCanvas.Children.Add(plg); } } if (cs.IsColorBar && IsColormap) { AddColorBar(cs, ds, zmin, zmax); } }
private void AddWaterfall(ChartStyle cs, DataSeriesSurface ds) { Matrix3D m = Utility.AzimuthElevation(cs.Elevation, cs.Azimuth); Polygon plg = new Polygon(); Point3D[,] pts = ds.PointArray; Point3D[] pt3 = new Point3D[pts.GetLength(0) + 2]; double[] zValues = new double[pts.Length]; Point[] pta = new Point[pts.GetLength(0) + 2]; double zmin = ds.ZDataMin(); double zmax = ds.ZDataMax(); for (int j = 0; j < pts.GetLength(1); j++) { int jj = j; if (cs.Elevation >= 0) { if (cs.Azimuth >= -90 && cs.Azimuth < 90) { jj = pts.GetLength(1) - 1 - j; } } else if (cs.Elevation < 0) { jj = pts.GetLength(1) - 1 - j; if (cs.Azimuth >= -90 && cs.Azimuth < 90) { jj = j; } } for (int i = 0; i < pts.GetLength(0); i++) { pt3[i + 1] = pts[i, jj]; if (i == 0) { pt3[0] = new Point3D(pt3[i + 1].X, pt3[i + 1].Y, cs.Zmin); } if (i == pts.GetLength(0) - 1) { pt3[pts.GetLength(0) + 1] = new Point3D(pt3[i + 1].X, pt3[i + 1].Y, cs.Zmin); } } plg = new Polygon(); for (int i = 0; i < pt3.Length; i++) { zValues[i] = pt3[i].Z; pt3[i] = cs.Normalize3D(m, pt3[i]); pta[i] = new Point(pt3[i].X, pt3[i].Y); plg.Points.Add(new Point(pt3[i].X, pt3[i].Y)); } plg.Stroke = Brushes.Transparent; plg.StrokeThickness = ds.LineThickness; plg.Fill = Brushes.White; cs.ChartCanvas.Children.Add(plg); for (int i = 1; i < pt3.Length; i++) { Line line = new Line(); line.Stroke = Brushes.Black; line.StrokeThickness = ds.LineThickness; if (IsColormap) { if (i < pt3.Length - 1) { line.Stroke = GetBrush(zValues[i], zmin, zmax); } else { line.Stroke = GetBrush(zValues[i - 1], zmin, zmax); } } line.X1 = pta[i - 1].X; line.Y1 = pta[i - 1].Y; line.X2 = pta[i].X; line.Y2 = pta[i].Y; cs.ChartCanvas.Children.Add(line); } } if (cs.IsColorBar && IsColormap) { AddColorBar(cs, ds, zmin, zmax); } }
private void AddMesh(ChartStyle cs, DataSeriesSurface ds) { Matrix3D m = Utility.AzimuthElevation(cs.Elevation, cs.Azimuth); Polygon plg = new Polygon(); Point3D[,] pts = ds.PointArray; double[,] zValues = new double[pts.GetLength(0), pts.GetLength(1)]; double zmin = ds.ZDataMin(); double zmax = ds.ZDataMax(); for (int i = 0; i < pts.GetLength(0); i++) { for (int j = 0; j < pts.GetLength(1); j++) { zValues[i, j] = pts[i, j].Z; pts[i, j] = cs.Normalize3D(m, pts[i, j]); } } // Draw mesh chart: for (int i = 0; i < pts.GetLength(0) - 1; i++) { int ii = i; if (cs.Elevation >= 0) { ii = i; if (cs.Azimuth >= -180 && cs.Azimuth < 0) { ii = pts.GetLength(0) - 2 - i; } } else { ii = pts.GetLength(0) - 2 - i; if (cs.Azimuth >= -180 && cs.Azimuth < 0) { ii = i; } } for (int j = 0; j < pts.GetLength(1) - 1; j++) { int jj = j; if (cs.Elevation < 0) { jj = pts.GetLength(1) - 2 - j; } plg = new Polygon(); plg.Points.Add(new Point(pts[ii, jj].X, pts[ii, jj].Y)); plg.Points.Add(new Point(pts[ii, jj + 1].X, pts[ii, jj + 1].Y)); plg.Points.Add(new Point(pts[ii + 1, jj + 1].X, pts[ii + 1, jj + 1].Y)); plg.Points.Add(new Point(pts[ii + 1, jj].X, pts[ii + 1, jj].Y)); plg.Stroke = Brushes.Black; plg.StrokeThickness = ds.LineThickness; plg.Fill = Brushes.White; if (IsHiddenLine) { plg.Fill = Brushes.Transparent; } if (IsColormap) { plg.Stroke = GetBrush(zValues[ii, jj], zmin, zmax); } cs.ChartCanvas.Children.Add(plg); } } if (cs.IsColorBar && IsColormap) { AddColorBar(cs, ds, zmin, zmax); } }