public AddBoundingBox ( System.Windows.Media.Media3D.Rect3D boundingBox, double diameter ) : void | ||
boundingBox | System.Windows.Media.Media3D.Rect3D | /// The bounding box. /// |
diameter | double | /// The diameter of the cylinders. /// |
return | void |
private Model3D CreateModel() { var plotModel = new Model3DGroup(); var axesMeshBuilder = new MeshBuilder(); _realRect3D = GetSampleImageBox(); axesMeshBuilder.AddBoundingBox(_realRect3D, 0.01); plotModel.Children.Add(new GeometryModel3D(axesMeshBuilder.ToMesh(), Materials.Yellow)); switch (CurrentDirection) { case FrameDirection.Top: CreateTopSelectionSlice(plotModel, SectionBrush); CreateTopMaxSlice(plotModel); CreateTopPartSlice(plotModel, SectionPosition); break; case FrameDirection.Front: CreateFrontSelectionSlice(plotModel, SectionBrush); CreateFrontMaxSlice(plotModel); CreateFrontPartSlice(plotModel, SectionPosition); break; case FrameDirection.Left: CreateLeftSelectionSlice(plotModel, SectionBrush); CreateLeftMaxSlice(plotModel); CreateLeftPartSlice(plotModel, SectionPosition); break; default: throw new InvalidOperationException("Can not process the direction."); } return plotModel; }
private Model3D CreateModel() { var plotModel = new Model3DGroup(); int rows = Points.GetUpperBound(0) + 1; int columns = Points.GetUpperBound(1) + 1; double minX = double.MaxValue; double maxX = double.MinValue; double minY = double.MaxValue; double maxY = double.MinValue; double minZ = double.MaxValue; double maxZ = double.MinValue; double minColorValue = double.MaxValue; double maxColorValue = double.MinValue; for (int i = 0; i < rows; i++) for (int j = 0; j < columns; j++) { double x = Points[i, j].X; double y = Points[i, j].Y; double z = Points[i, j].Z; maxX = Math.Max(maxX, x); maxY = Math.Max(maxY, y); maxZ = Math.Max(maxZ, z); minX = Math.Min(minX, x); minY = Math.Min(minY, y); minZ = Math.Min(minZ, z); if (ColorValues != null) { maxColorValue = Math.Max(maxColorValue, ColorValues[i, j]); minColorValue = Math.Min(minColorValue, ColorValues[i, j]); } } // make color value 0 at texture coordinate 0.5 if (Math.Abs(minColorValue) < Math.Abs(maxColorValue)) minColorValue = -maxColorValue; else maxColorValue = -minColorValue; // set the texture coordinates by z-value or ColorValue var texcoords = new Point[rows,columns]; for (int i = 0; i < rows; i++) for (int j = 0; j < columns; j++) { double u = (Points[i, j].Z - minZ)/(maxZ - minZ); if (ColorValues != null) u = (ColorValues[i, j] - minColorValue)/(maxColorValue - minColorValue); texcoords[i, j] = new Point(u, u); } var surfaceMeshBuilder = new MeshBuilder(); surfaceMeshBuilder.AddRectangularMesh(Points, texcoords); var surfaceModel = new GeometryModel3D(surfaceMeshBuilder.ToMesh(), MaterialHelper.CreateMaterial(SurfaceBrush, null, null, 1, 0)); surfaceModel.BackMaterial = surfaceModel.Material; var axesMeshBuilder = new MeshBuilder(); for (double x = minX; x <= maxX; x += IntervalX) { double j = (x - minX)/(maxX - minX)*(columns - 1); var path = new List<Point3D> {new Point3D(x, minY, minZ)}; for (int i = 0; i < rows; i++) { path.Add(BilinearInterpolation(Points, i, j)); } path.Add(new Point3D(x, maxY, minZ)); axesMeshBuilder.AddTube(path, LineThickness, 9, false); GeometryModel3D label = TextCreator.CreateTextLabelModel3D(x.ToString(), Brushes.Black, true, FontSize, new Point3D(x, minY - FontSize*2.5, minZ), new Vector3D(1, 0, 0), new Vector3D(0, 1, 0)); plotModel.Children.Add(label); } { GeometryModel3D label = TextCreator.CreateTextLabelModel3D("X-axis", Brushes.Black, true, FontSize, new Point3D((minX + maxX)*0.5, minY - FontSize*6, minZ), new Vector3D(1, 0, 0), new Vector3D(0, 1, 0)); plotModel.Children.Add(label); } for (double y = minY; y <= maxY; y += IntervalY) { double i = (y - minY)/(maxY - minY)*(rows - 1); var path = new List<Point3D> {new Point3D(minX, y, minZ)}; for (int j = 0; j < columns; j++) { path.Add(BilinearInterpolation(Points, i, j)); } path.Add(new Point3D(maxX, y, minZ)); axesMeshBuilder.AddTube(path, LineThickness, 9, false); GeometryModel3D label = TextCreator.CreateTextLabelModel3D(y.ToString(), Brushes.Black, true, FontSize, new Point3D(minX - FontSize*3, y, minZ), new Vector3D(1, 0, 0), new Vector3D(0, 1, 0)); plotModel.Children.Add(label); } { GeometryModel3D label = TextCreator.CreateTextLabelModel3D("Y-axis", Brushes.Black, true, FontSize, new Point3D(minX - FontSize*10, (minY + maxY)*0.5, minZ), new Vector3D(0, 1, 0), new Vector3D(-1, 0, 0)); plotModel.Children.Add(label); } double z0 = (int) (minZ/IntervalZ)*IntervalZ; for (double z = z0; z <= maxZ + double.Epsilon; z += IntervalZ) { GeometryModel3D label = TextCreator.CreateTextLabelModel3D(z.ToString(), Brushes.Black, true, FontSize, new Point3D(minX - FontSize*3, maxY, z), new Vector3D(1, 0, 0), new Vector3D(0, 0, 1)); plotModel.Children.Add(label); } { GeometryModel3D label = TextCreator.CreateTextLabelModel3D("Z-axis", Brushes.Black, true, FontSize, new Point3D(minX - FontSize*10, maxY, (minZ + maxZ)*0.5), new Vector3D(0, 0, 1), new Vector3D(1, 0, 0)); plotModel.Children.Add(label); } var bb = new Rect3D(minX, minY, minZ, maxX - minX, maxY - minY, 0*(maxZ - minZ)); axesMeshBuilder.AddBoundingBox(bb, LineThickness); var axesModel = new GeometryModel3D(axesMeshBuilder.ToMesh(), Materials.Black); plotModel.Children.Add(surfaceModel); plotModel.Children.Add(axesModel); return plotModel; }
private Model3D CreateModel() { // if (Points ==null) var plotModel = new Model3DGroup(); int rows = Points.GetUpperBound(0) + 1; int columns = Points.GetUpperBound(1) + 1; double minX = double.MaxValue; double maxX = double.MinValue; double minY = double.MaxValue; double maxY = double.MinValue; double minZ = double.MaxValue; double maxZ = double.MinValue; //double RealminX = double.MaxValue; //double RealmaxX = double.MinValue; //double RealminY = double.MaxValue; //double RealmaxY = double.MinValue; //double RealminZ = double.MaxValue; //double RealmaxZ = double.MinValue; #region Color things double minColorValue = double.MaxValue; double maxColorValue = double.MinValue; for (int i = 0; i < rows; i++) for (int j = 0; j < columns; j++) { double x = Points[i, j].X; double y = Points[i, j].Y; double z = Points[i, j].Z; maxX = Math.Max(maxX, x); maxY = Math.Max(maxY, y); maxZ = Math.Max(maxZ, z); minX = Math.Min(minX, x); minY = Math.Min(minY, y); minZ = Math.Min(minZ, z); if (ColorValues != null) { maxColorValue = Math.Max(maxColorValue, ColorValues[i, j]); minColorValue = Math.Min(minColorValue, ColorValues[i, j]); } } // make color value 0 at texture coordinate 0.5 if (Math.Abs(minColorValue) < Math.Abs(maxColorValue)) minColorValue = -maxColorValue; else maxColorValue = -minColorValue; #endregion // set the texture coordinates by z-value or ColorValue var texcoords = new Point[rows,columns]; if (OriginalData == null || ColorCoding != ComplexPlainVisualizer.ColorCoding.Custom) { for (int i = 0; i < rows; i++) for (int j = 0; j < columns; j++) { double u = (Points[i, j].Z - minZ) / (maxZ - minZ); //double v = if (ColorValues != null) u = (ColorValues[i, j] - minColorValue) / (maxColorValue - minColorValue); texcoords[i, j] = new Point(u, u); } } else { for (int i = 0; i < rows; i++) for (int j = 0; j < columns; j++) { double u = MathUtil.Scale(minZ, maxZ, Math.Log10(OriginalData[i, j].Z), 0.5); double v = OriginalData[i, j].W; double uu = 0.5 + u * Math.Cos(v); double vv = 0.5 + u * Math.Sin(v); texcoords[i, j] = new Point(uu, vv); } } if (AutoScale) { ScaleX =10 / Math.Abs(maxX - minX); ScaleY =10/ Math.Abs(maxY - minY); ScaleZ =5 / Math.Abs(maxZ - minZ); } var surfaceMeshBuilder = new MeshBuilder(); surfaceMeshBuilder.AddRectangularMesh(Points, texcoords); surfaceMeshBuilder.Scale(ScaleX, ScaleY, ScaleZ); var surfaceModel = new GeometryModel3D(surfaceMeshBuilder.ToMesh(), MaterialHelper.CreateMaterial(SurfaceBrush, null, null, 1, 0)); surfaceModel.BackMaterial = surfaceModel.Material; //RealmaxX = maxX; //RealminX = minX; //RealmaxY = maxY; //RealminY = minY; //RealmaxZ = maxZ; //RealminZ = minZ; maxX *= ScaleX; minX *= ScaleX; maxY *= ScaleY; minY *= ScaleY; maxZ *= ScaleZ; minZ *= ScaleZ; IntervalX = (maxX - minX) / SubAxisCount; IntervalY = (maxY - minY) / SubAxisCount; IntervalZ = (maxZ - minZ) / SubAxisCount; #region eje x var axesMeshBuilder = new MeshBuilder(); for (double x = minX; x <= maxX; x += IntervalX) { double j = (x - minX)/(maxX - minX)*(columns - 1); //var path = new List<Point3D> { new Point3D(x , minY , minZ) }; var path = new List<Point3D> { new Point3D(x, minY , minZ) }; for (int i = 0; i < rows; i++) { Point3D p = BilinearInterpolation(Points, i, j); p.X *= ScaleX; p.Y *= ScaleY; p.Z *= ScaleZ; path.Add(p); } path.Add(new Point3D(x, maxY, minZ)); axesMeshBuilder.AddTube(path, LineThickness, 9, false); GeometryModel3D label = TextCreator.CreateTextLabelModel3D(StringUtils.CodeString(x / ScaleX), Brushes.Black, true, FontSize, new Point3D(x, minY - FontSize * 2.5, minZ), new Vector3D(1, 0, 0), new Vector3D(0, 1, 0)); plotModel.Children.Add(label); } { GeometryModel3D label = TextCreator.CreateTextLabelModel3D("X-axis", Brushes.Black, true, FontSize, new Point3D((minX + maxX)*0.5, minY - FontSize * 6, minZ), new Vector3D(1, 0, 0), new Vector3D(0, 1, 0)); plotModel.Children.Add(label); } #endregion #region eje y for (double y = minY; y <= maxY; y += IntervalY) { double i = (y - minY)/(maxY - minY)*(rows - 1); var path = new List<Point3D> {new Point3D(minX, y, minZ)}; for (int j = 0; j < columns; j++) { Point3D p = BilinearInterpolation(Points, i, j); p.X *= ScaleX; p.Y *= ScaleY; p.Z *= ScaleZ; path.Add(p); } path.Add(new Point3D(maxX, y, minZ)); axesMeshBuilder.AddTube(path, LineThickness, 9, false); GeometryModel3D label = TextCreator.CreateTextLabelModel3D(StringUtils.CodeString(y / ScaleY), Brushes.Black, true, FontSize, new Point3D(minX - FontSize * 3, y, minZ), new Vector3D(1, 0, 0), new Vector3D(0, 1, 0)); plotModel.Children.Add(label); } { GeometryModel3D label = TextCreator.CreateTextLabelModel3D("Y-axis", Brushes.Black, true, FontSize, new Point3D(minX - FontSize * 10, (minY + maxY) * 0.5, minZ), new Vector3D(0, 1, 0), new Vector3D(-1, 0, 0)); plotModel.Children.Add(label); } #endregion #region eje z double z0 = (int) (minZ/IntervalZ)*IntervalZ; for (double z = z0; z <= maxZ + double.Epsilon; z += IntervalZ) { GeometryModel3D label = TextCreator.CreateTextLabelModel3D(StringUtils.CodeString(z / ScaleZ), Brushes.Black, true, FontSize, new Point3D(minX - FontSize * 3, maxY, z), new Vector3D(1, 0, 0), new Vector3D(0, 0, 1)); plotModel.Children.Add(label); } { GeometryModel3D label = TextCreator.CreateTextLabelModel3D("Z-axis", Brushes.Black, true, FontSize, new Point3D(minX - FontSize * 10, maxY, (minZ + maxZ)*0.5), new Vector3D(0, 0, 1), new Vector3D(1, 0, 0)); plotModel.Children.Add(label); } #endregion var bb = new Rect3D(minX, minY, minZ, maxX - minX, maxY - minY, 0*(maxZ - minZ)); axesMeshBuilder.AddBoundingBox(bb, LineThickness); var axesModel = new GeometryModel3D(axesMeshBuilder.ToMesh(), Materials.Black); plotModel.Children.Add(surfaceModel); plotModel.Children.Add(axesModel); return plotModel; }
private Model3D CreateModel() { if (Points == null || Points.Length == 0) return null; var plotModel = new Model3DGroup(); int rows = Points.GetUpperBound(0) + 1; int columns = Points.GetUpperBound(1) + 1; double minX = double.MaxValue; double maxX = double.MinValue; double minY = double.MaxValue; double maxY = double.MinValue; double minZ = double.MaxValue; double maxZ = double.MinValue; double minColorValue = double.MaxValue; double maxColorValue = double.MinValue; minX = Points.OfType<Point3D>().Min(x => x.X); maxX = Points.OfType<Point3D>().Max(x => x.X); minY = Points.OfType<Point3D>().Min(x => x.Y); maxY = Points.OfType<Point3D>().Max(x => x.Y); minZ = Points.OfType<Point3D>().Min(x => x.Z); maxZ = Points.OfType<Point3D>().Max(x => x.Z); if (ColorValues != null) minColorValue = ColorValues.OfType<double>().Min(x => x); if (ColorValues != null) maxColorValue = ColorValues.OfType<double>().Max(x => x); if (Functions.Abs(minColorValue) < Functions.Abs(maxColorValue)) minColorValue = -maxColorValue; else maxColorValue = -minColorValue; BitmapPixelMaker bm_maker = new BitmapPixelMaker(columns, rows); for (int ix = 0; ix < columns; ix++) { for (int iy = 0; iy < rows; iy++) { try { byte red, green, blue; MapRainbowColor(Points[ix, iy].Z, minZ, maxZ, out red, out green, out blue); bm_maker.SetPixel(ix, iy, red, green, blue, 255); } catch { } } } var texcoords = new Point[rows, columns]; for (int i = 0; i < rows; i++) for (int j = 0; j < columns; j++) { texcoords[i, j] = new Point(i, j); } var surfaceMeshBuilder = new MeshBuilder(); surfaceMeshBuilder.AddRectangularMesh(Points, texcoords); var surfaceModel = new GeometryModel3D(surfaceMeshBuilder.ToMesh(), MaterialHelper.CreateMaterial(new ImageBrush(bm_maker.MakeBitmap(128, 128)), null, null, 1, 0)); surfaceModel.BackMaterial = surfaceModel.Material; var axesMeshBuilder = new MeshBuilder(); for (double x = minX; x <= maxX; x += IntervalX) { double j = (x - minX) / (maxX - minX) * (columns - 1); var path = new List<Point3D> {new Point3D(x, minY, minZ)}; for (int i = 0; i < rows; i++) { path.Add(BilinearInterpolation(Points, i, j)); } path.Add(new Point3D(x, maxY, minZ)); axesMeshBuilder.AddTube(path, LineThickness, 9, false); GeometryModel3D label = TextCreator.CreateTextLabelModel3D(x.ToString(), Brushes.Black, true, FontSize * 3, new Point3D(x, minY - FontSize * 2.5, minZ), new Vector3D(1, 0, 0), new Vector3D(0, 1, 0)); plotModel.Children.Add(label); } { GeometryModel3D label = TextCreator.CreateTextLabelModel3D("Axe réel", Brushes.Black, true, FontSize * 10, new Point3D((minX + maxX) * 0.25, minY - FontSize * 6 - 0.5, minZ), new Vector3D(1, 0, 0), new Vector3D(0, 1, 0)); plotModel.Children.Add(label); } for (double y = minY; y <= maxY; y += IntervalY) { double i = (y - minY) / (maxY - minY) * (rows - 1); var path = new List<Point3D> {new Point3D(minX, y, minZ)}; for (int j = 0; j < columns; j++) { path.Add(BilinearInterpolation(Points, i, j)); } path.Add(new Point3D(maxX, y, minZ)); axesMeshBuilder.AddTube(path, LineThickness, 9, false); GeometryModel3D label = TextCreator.CreateTextLabelModel3D(y.ToString(), Brushes.Black, true, FontSize * 3, new Point3D(minX - FontSize * 3, y, minZ), new Vector3D(0, 1, 0), new Vector3D(1, 0, 0)); plotModel.Children.Add(label); } { GeometryModel3D label = TextCreator.CreateTextLabelModel3D("Axe imaginaire", Brushes.Black, true, FontSize * 10, new Point3D(minX - FontSize * 10, (minY + maxY) * 0.5, minZ), new Vector3D(0, 1, 0), new Vector3D(1, 0, 0)); plotModel.Children.Add(label); } double z0 = (int) (minZ / IntervalZ) * IntervalZ; for (double z = z0; z <= maxZ + double.Epsilon; z += IntervalZ) { GeometryModel3D label = TextCreator.CreateTextLabelModel3D(z.ToString(), Brushes.Black, true, FontSize * 3, new Point3D(minX - FontSize * 3, maxY, z), new Vector3D(1, 0, 0), new Vector3D(0, 0, 1)); plotModel.Children.Add(label); } { GeometryModel3D label = TextCreator.CreateTextLabelModel3D("Module", Brushes.Black, true, FontSize * 10, new Point3D(minX - FontSize * 10 - 1.5, maxY, (minZ + maxZ) * 0.5), new Vector3D(1, 0, 0), new Vector3D(0, 0, 1)); plotModel.Children.Add(label); } var bb = new Rect3D(minX, minY, minZ, maxX - minX, maxY - minY, (maxZ - minZ)); axesMeshBuilder.AddBoundingBox(bb, LineThickness); var axesModel = new GeometryModel3D(axesMeshBuilder.ToMesh(), Materials.Black); plotModel.Children.Add(surfaceModel); plotModel.Children.Add(axesModel); return plotModel; }
/// <summary> /// This function creates the model /// </summary> /// <returns>A created plot model</returns> private Model3D CreateModel() { var plotModel = new Model3DGroup(); if (Points == null || Points.Count == 0) return plotModel; double minX = Points.Min(p => p.X); double maxX = Points.Max(p => p.X); double minY = Points.Min(p => p.Y); double maxY = Points.Max(p => p.Y); double minZ = Points.Min(p => p.Z); double maxZ = Points.Max(p => p.Z); double minValue = 0; double maxValue = 10000; var valueRange = maxValue - minValue; var scatterMeshBuilder = new MeshBuilder(true, true); var oldTCCount = 0; for (var i = 0; i < Points.Count; ++i) { scatterMeshBuilder.AddSphere(Points[i], SphereSize, 4, 4); var newTCCount = scatterMeshBuilder.TextureCoordinates.Count; oldTCCount = newTCCount; } var scatterModel = new GeometryModel3D(scatterMeshBuilder.ToMesh(), MaterialHelper.CreateMaterial(SurfaceBrush, null, null, 1, 0)); scatterModel.BackMaterial = scatterModel.Material; // create bounding box with axes indications var axesMeshBuilder = new MeshBuilder(); for (double x = minX; x <= maxX; x += IntervalX) { GeometryModel3D label = TextCreator.CreateTextLabelModel3D(x.ToString(), Brushes.White, true, FontSize, new Point3D(x, minY - FontSize * 2.5, minZ), new Vector3D(1, 0, 0), new Vector3D(0, 1, 0)); plotModel.Children.Add(label); } { GeometryModel3D label = TextCreator.CreateTextLabelModel3D("X-axis", Brushes.White, true, FontSize, new Point3D((minX + maxX) * 0.5, minY - FontSize * 6, minZ), new Vector3D(1, 0, 0), new Vector3D(0, 1, 0)); plotModel.Children.Add(label); } for (double y = minY; y <= maxY; y += IntervalY) { GeometryModel3D label = TextCreator.CreateTextLabelModel3D(y.ToString(), Brushes.White, true, FontSize, new Point3D(minX - FontSize * 3, y, minZ), new Vector3D(1, 0, 0), new Vector3D(0, 1, 0)); plotModel.Children.Add(label); } { GeometryModel3D label = TextCreator.CreateTextLabelModel3D("Y-axis", Brushes.White, true, FontSize, new Point3D(minX - FontSize * 10, (minY + maxY) * 0.5, minZ), new Vector3D(0, 1, 0), new Vector3D(-1, 0, 0)); plotModel.Children.Add(label); } double z0 = (int)(minZ / IntervalZ) * IntervalZ; for (double z = z0; z <= maxZ + double.Epsilon; z += IntervalZ) { GeometryModel3D label = TextCreator.CreateTextLabelModel3D(z.ToString(), Brushes.White, true, FontSize, new Point3D(minX - FontSize * 3, maxY, z), new Vector3D(1, 0, 0), new Vector3D(0, 0, 1)); plotModel.Children.Add(label); } { GeometryModel3D label = TextCreator.CreateTextLabelModel3D("Z-axis", Brushes.White, true, FontSize, new Point3D(minX - FontSize * 10, maxY, (minZ + maxZ) * 0.5), new Vector3D(0, 0, 1), new Vector3D(1, 0, 0)); plotModel.Children.Add(label); } var bb = new Rect3D(minX, minY, minZ, maxX - minX, maxY - minY, maxZ - minZ); axesMeshBuilder.AddBoundingBox(bb, LineThickness); var axesModel = new GeometryModel3D(axesMeshBuilder.ToMesh(), Materials.White); plotModel.Children.Add(scatterModel); plotModel.Children.Add(axesModel); return plotModel; }
private Model3D CreateModel() { bool isCylindarMode = CylindarMode && ExpendedBrush != null && (SlideDirection == CooridinateDirection.ZN || SlideDirection == CooridinateDirection.ZP); bool isIntersectionmode = IntersectionMode && SectionBrush != null; bool isIntersectedCylindarMode = isCylindarMode && isIntersectionmode; var plotModel = new Model3DGroup(); var axesMeshBuilder = new MeshBuilder(); _realRect3D = GetSampleImageBox(); axesMeshBuilder.AddBoundingBox(_realRect3D, 0.01); plotModel.Children.Add(new GeometryModel3D(axesMeshBuilder.ToMesh(), Materials.Yellow)); var flipTransform = new ScaleTransform(1, -1, 0.5, 0.5); var znBrush = ZNBrush?.Clone(); var zpBrush = ZPBrush?.Clone(); if (zpBrush != null) { zpBrush.Transform = flipTransform; } var ynBrush = YNBrush?.Clone(); var ypBrush = YPBrush?.Clone(); if (ypBrush != null) { ypBrush.Transform = flipTransform; } var xnBrush = XNBrush?.Clone(); var xpBrush = XPBrush?.Clone(); if (xpBrush != null) { xpBrush.Transform = flipTransform; } var expBrush = ExpendedBrush?.Clone(); Rect3D rectDraw = _realRect3D; if (isIntersectionmode) { switch (SlideDirection) { case CooridinateDirection.XP: { rectDraw.SizeX = SectionPosition; xpBrush = SectionBrush.Clone(); xpBrush.Transform = flipTransform; double c = SectionPosition / _realRect3D.SizeX; ynBrush.Viewbox = new Rect(0, 0, 1, c); ypBrush.Viewbox = new Rect(0, 0, 1, c); znBrush.Viewbox = new Rect(0, 0, c, 1); zpBrush.Viewbox = new Rect(0, 0, c, 1); } break; case CooridinateDirection.XN: { rectDraw.X = SectionPosition; rectDraw.SizeX -= rectDraw.X; xnBrush = SectionBrush.Clone(); double c = SectionPosition / _realRect3D.SizeX; ynBrush.Viewbox = new Rect(0, c, 1, 1 - c); ypBrush.Viewbox = new Rect(0, c, 1, 1 - c); znBrush.Viewbox = new Rect(c, 0, 1 - c, 1); zpBrush.Viewbox = new Rect(c, 0, 1 - c, 1); } break; case CooridinateDirection.YP: { rectDraw.SizeY = SectionPosition; ypBrush = SectionBrush.Clone(); ypBrush.Transform = flipTransform; double c = SectionPosition / _realRect3D.SizeY; xnBrush.Viewbox = new Rect(0, 0, c, 1); xpBrush.Viewbox = new Rect(0, 0, c, 1); znBrush.Viewbox = new Rect(0, 0, 1, c); zpBrush.Viewbox = new Rect(0, 0, 1, c); } break; case CooridinateDirection.YN: { rectDraw.Y = SectionPosition; rectDraw.SizeY -= rectDraw.Y; ynBrush = SectionBrush.Clone(); double c = SectionPosition / _realRect3D.SizeY; xnBrush.Viewbox = new Rect(c, 0, 1 - c, 1); xpBrush.Viewbox = new Rect(c, 0, 1 - c, 1); znBrush.Viewbox = new Rect(0, c, 1, 1 - c); zpBrush.Viewbox = new Rect(0, c, 1, 1 - c); } break; case CooridinateDirection.ZP: { rectDraw.SizeZ = SectionPosition; zpBrush = SectionBrush.Clone(); zpBrush.Transform = flipTransform; double c = SectionPosition / _realRect3D.SizeZ; ynBrush.Viewbox = new Rect(0, 0, c, 1); ypBrush.Viewbox = new Rect(0, 0, c, 1); xnBrush.Viewbox = new Rect(0, 0, 1, c); xpBrush.Viewbox = new Rect(0, 0, 1, c); expBrush.Viewbox = new Rect(0, 0, 1, c); } break; case CooridinateDirection.ZN: { rectDraw.Z = SectionPosition; rectDraw.SizeZ -= rectDraw.Z; znBrush = SectionBrush.Clone(); double c = SectionPosition / _realRect3D.SizeZ; ynBrush.Viewbox = new Rect(c, 0, 1 - c, 1); ypBrush.Viewbox = new Rect(c, 0, 1 - c, 1); xnBrush.Viewbox = new Rect(0, c, 1, 1 - c); xpBrush.Viewbox = new Rect(0, c, 1, 1 - c); expBrush.Viewbox = new Rect(0, c, 1, 1 - c); } break; default: break; } } MeshBuilder mb = null; if (!isCylindarMode) { // draw faces in z directions mb = new MeshBuilder(); mb.AddRectangularMesh( new[] { new Point3D(rectDraw.X,rectDraw.Y,rectDraw.Z), //0,0,0 new Point3D(rectDraw.X+rectDraw.SizeX,rectDraw.Y,rectDraw.Z), //1,0,0 new Point3D(rectDraw.X,rectDraw.Y+rectDraw.SizeY,rectDraw.Z), //0,1,0 new Point3D(rectDraw.X+rectDraw.SizeX,rectDraw.Y+rectDraw.SizeY,rectDraw.Z) //1,1,0 }, 2); plotModel.Children.Add(new GeometryModel3D(mb.ToMesh(), MaterialHelper.CreateMaterial(znBrush))); mb = new MeshBuilder(); mb.AddRectangularMesh( new[] { new Point3D(rectDraw.X,rectDraw.Y+rectDraw.SizeY,rectDraw.Z+rectDraw.SizeZ), // 0,1,1 new Point3D(rectDraw.X+rectDraw.SizeX,rectDraw.Y+rectDraw.SizeY,rectDraw.Z+rectDraw.SizeZ), // 1,1,1 new Point3D(rectDraw.X,rectDraw.Y,rectDraw.Z+rectDraw.SizeZ), // 0,0,1 new Point3D(rectDraw.X+rectDraw.SizeX,rectDraw.Y,rectDraw.Z+rectDraw.SizeZ) // 1,0,1 } , 2); plotModel.Children.Add(new GeometryModel3D(mb.ToMesh(), MaterialHelper.CreateMaterial(zpBrush))); // draw faces in y directions mb = new MeshBuilder(); mb.AddRectangularMesh( new[] { new Point3D(rectDraw.X,rectDraw.Y,rectDraw.Z), new Point3D(rectDraw.X,rectDraw.Y,rectDraw.Z+rectDraw.SizeZ), new Point3D(rectDraw.X+rectDraw.SizeX,rectDraw.Y,rectDraw.Z), new Point3D(rectDraw.X+rectDraw.SizeX,rectDraw.Y,rectDraw.Z+rectDraw.SizeZ) }, 2); plotModel.Children.Add(new GeometryModel3D(mb.ToMesh(), MaterialHelper.CreateMaterial(ynBrush))); mb = new MeshBuilder(); mb.AddRectangularMesh( new[] { new Point3D(rectDraw.X+rectDraw.SizeX,rectDraw.Y+rectDraw.SizeY,rectDraw.Z), new Point3D(rectDraw.X+rectDraw.SizeX,rectDraw.Y+rectDraw.SizeY,rectDraw.Z+rectDraw.SizeZ), new Point3D(rectDraw.X,rectDraw.Y+rectDraw.SizeY,rectDraw.Z), new Point3D(rectDraw.X,rectDraw.Y+rectDraw.SizeY,rectDraw.Z+rectDraw.SizeZ) }, 2); plotModel.Children.Add(new GeometryModel3D(mb.ToMesh(), MaterialHelper.CreateMaterial(ypBrush))); // draw faces in x directions mb = new MeshBuilder(); mb.AddRectangularMesh( new[] { new Point3D(rectDraw.X,rectDraw.Y,rectDraw.Z), new Point3D(rectDraw.X,rectDraw.Y+rectDraw.SizeY,rectDraw.Z), new Point3D(rectDraw.X,rectDraw.Y,rectDraw.Z+rectDraw.SizeZ), new Point3D(rectDraw.X,rectDraw.Y+rectDraw.SizeY,rectDraw.Z+rectDraw.SizeZ) }, 2); plotModel.Children.Add(new GeometryModel3D(mb.ToMesh(), MaterialHelper.CreateMaterial(xnBrush))); mb = new MeshBuilder(); mb.AddRectangularMesh( new[] { new Point3D(rectDraw.X+rectDraw.SizeX,rectDraw.Y,rectDraw.Z+rectDraw.SizeZ), new Point3D(rectDraw.X+rectDraw.SizeX,rectDraw.Y+rectDraw.SizeY,rectDraw.Z+rectDraw.SizeZ), new Point3D(rectDraw.X+rectDraw.SizeX,rectDraw.Y,rectDraw.Z), new Point3D(rectDraw.X+rectDraw.SizeX,rectDraw.Y+rectDraw.SizeY,rectDraw.Z) }, 2); plotModel.Children.Add(new GeometryModel3D(mb.ToMesh(), MaterialHelper.CreateMaterial(xpBrush))); } if (isCylindarMode) { int div = 121; mb = new MeshBuilder(); double s = Math.Min(_realRect3D.SizeX, _realRect3D.SizeY); double shiftx = (_realRect3D.SizeX - s) / 2; double shifty = (_realRect3D.SizeY - s) / 2; var startCentre = new Point3D(Centre.X * s + shiftx, Centre.Y * s + shifty, rectDraw.Z); var endCentre = new Point3D(Centre.X * s + shiftx, Centre.Y * s + shifty, rectDraw.Z + rectDraw.SizeZ); double r = Radius * s; mb.AddCylindarZ(startCentre, r, rectDraw.SizeZ, div); plotModel.Children.Add(new GeometryModel3D(mb.ToMesh(), MaterialHelper.CreateMaterial(expBrush))); mb = new MeshBuilder(); mb.AddCircleInZCross(startCentre, r, div, false); znBrush.Viewbox = new Rect((startCentre.X - r) / _realRect3D.SizeX, (startCentre.Y - r) / _realRect3D.SizeY, (2 * r) / _realRect3D.SizeX, (2 * r) / _realRect3D.SizeY); plotModel.Children.Add(new GeometryModel3D(mb.ToMesh(), MaterialHelper.CreateMaterial(znBrush))); mb = new MeshBuilder(); mb.AddCircleInZCross(endCentre, r, div, true); zpBrush.Viewbox = new Rect((startCentre.X - r) / _realRect3D.SizeX, (startCentre.Y - r) / _realRect3D.SizeY, (2 * r) / _realRect3D.SizeX, (2 * r) / _realRect3D.SizeY); zpBrush.Transform = null; plotModel.Children.Add(new GeometryModel3D(mb.ToMesh(), MaterialHelper.CreateMaterial(zpBrush))); } return plotModel; }