private void SetDraw(object sender, RoutedEventArgs e) { if (checkDraw.IsChecked.GetValueOrDefault()) { tmpArrete = new LinesVisual3D(); tmpArrete.Color = colorLines; tmpArrete.Thickness = 0.01; tmpPoints = new PointsVisual3D(); tmpPoints.Color = colorPoints; tmpPoints.Size = 0.05; bufArrete = new Point3DCollection(); bufPoint = new Point3DCollection(); listePoints.Add(tmpPoints); listeLignes.Add(tmpArrete); ViewPort.Children.Add(listeLignes.Last()); ViewPort.Children.Add(listePoints.Last()); nbTraits.Content = "Nombre de traits : " + listeLignes.Count; timer.Tick += new EventHandler(drawPoints); timer.Start(); } }
//create a data object that stores the points to be loaded into the viewer private PointsVisual3D GetPointCloudData(string file, Color c) { Point3DCollection dataList = new Point3DCollection(); //read all lines in the file into an array string[] points = File.ReadAllLines(file); foreach (string point in points) { //if the line starts with a number or a negative sign (-) if (Regex.IsMatch(point, @"^\d+") || point.StartsWith("-")) { //split the line based on white space, and if it has 3 or more parts add it to the list string[] parts = point.Split(' '); if (parts.Length >= 3) { dataList.Add(new Point3D(double.Parse(parts[0]), double.Parse(parts[1]), double.Parse(parts[2]))); } } } //create the PointsVisual3D to store the point data and set up parameters PointsVisual3D cloudPoints = new PointsVisual3D(); cloudPoints.Color = c; cloudPoints.Size = 2; cloudPoints.Points = dataList; return(cloudPoints); }
private void ConvertPointShow(string path) { if (path == "") { return; } //ReadP3DTxt.ReadTxtPoint3DsOutZoom(ref rpListConvert, path, 13, 6, out Point3D pCenter); //显示鞋子的模型 if (!vp.Children.Contains(pointsVisualConvert)) { this.pointsVisualConvert = new PointsVisual3D { Color = Colors.OrangeRed, Size = 2 }; vp.Children.Add(this.pointsVisualConvert); } this.PointsConvert = new Point3DCollection(GeneratePointsConvert()); this.pointsVisualConvert.Points = this.PointsConvert; //create360(); //显示别选择物框 //this.DataContext = this.viewModel = new ViewModel(); //this.viewModel.Select(this.pointsVisual); //model3DGroup = new Model3DGroup(); //model3DGroup.Children.Add(this.pointsVisual); }
public void Load(string fileName) { var probing = DataContext as ProbingViewModel; probing.HeightMap.HasHeightMap = false; probing.HeightMap.Map = HeightMap.Load(fileName); probing.HeightMap.GridSize = probing.HeightMap.Map.GridX; probing.HeightMap.MinX = probing.HeightMap.Map.Min.X; probing.HeightMap.MinY = probing.HeightMap.Map.Min.Y; probing.HeightMap.MaxX = probing.HeightMap.Map.Max.X; probing.HeightMap.MaxY = probing.HeightMap.Map.Max.Y; LinesVisual3D boundary = new LinesVisual3D(); PointsVisual3D mapPoints = new PointsVisual3D(); MeshGeometryVisual3D mesh = new MeshGeometryVisual3D(); // TODO: fix HeightMap object... probing.HeightMap.Map.GetModel(mesh); probing.HeightMap.Map.GetPreviewModel(boundary, mapPoints); probing.HeightMap.MeshGeometry = mesh.MeshGeometry; probing.HeightMap.BoundaryPoints = boundary.Points; probing.HeightMap.MapPoints = mapPoints.Points; probing.HeightMap.HasHeightMap = true; }
/// <summary> /// Initializes a new instance of the <see cref="PointCloud3DVisualizationObject"/> class. /// </summary> public PointCloud3DVisualizationObject() { this.pointsVisual3D = new PointsVisual3D() { Color = this.color, Size = this.pointSize, }; }
/// <inheritdoc/> protected override void InitNew() { this.PropertyChanged += this.VisualizationPropertyChanged; this.Visual3D = this.pointsVisual = new PointsVisual3D() { Size = this.PointSize, Color = this.Color, }; base.InitNew(); }
private void VertexTreeViewItemSelected(object sender, RoutedEventArgs e) { if (LastPoint3D != null) { LastPoint3D.Color = Colors.White; } LastPoint3D = ((sender as TreeViewItem).Tag as PointsVisual3D); LastPoint3D.Color = Colors.LightGreen; }
/// <summary> /// Initializes a new instance of the <see cref="DepthImagePointCloudVisual3D"/> class. /// </summary> public DepthImagePointCloudVisual3D() { this.pointsVisual3D = new PointsVisual3D() { Color = this.color, Size = this.size, }; this.Children.Add(this.pointsVisual3D); }
public void AddPoint(wPoint WindPoint, wColor WindColor, double Radius) { PointsVisual3D VisPoint = new PointsVisual3D(); VisPoint.Size = Radius; VisPoint.Color = WindColor.ToMediaColor(); VisPoint.Points.Add(WindPoint.ToPoint3D()); ViewPort.Children.Add(VisPoint); }
private void ExportTxtBtnClick(object sender, RoutedEventArgs e) { //Point3DCollection modelMeshPositions = modelMesh.Positions; //Point3DCollection recMeshPositions = rectangleMesh.Positions; //Point3DCollection intersection = new Point3DCollection(); //MeshBuilder meshb = new MeshBuilder(); //foreach(Point3D modelPoint in modelMeshPositions) //{ // foreach(Point3D recPoint in recMeshPositions) // { // if ((Math.Round(modelPoint.X) == Math.Round(recPoint.X)) && (Math.Round(modelPoint.Y) == Math.Round(recPoint.Y))) // { // intersection.Add(modelPoint); // meshb.Positions.Add(modelPoint); // } // } //} MeshGeometry3D newmesh = new MeshGeometry3D(); ModelLPoints lp = new ModelLPoints(); newmesh = lp.BuildDic(modelMesh); Material material = new DiffuseMaterial(new SolidColorBrush(Colors.Red)); GeometryModel3D surface_model = new GeometryModel3D(newmesh, material); groupModel.Children.Clear(); this.viewPort3d.Children.Remove(device3D); surface_model.BackMaterial = material; groupModel.Children.Add(surface_model); device3D.Content = groupModel; Point3DCollection pc = lp.FillSensorDataDictionary(sensorsDataList); var vis = new PointsVisual3D() { Points = pc }; // Add to view port //this.viewPort3d.Children.Add(device3D); this.viewPort3d.Children.Add(vis); this.viewPort3d.ZoomExtents(); }
private void OnCompleted() { bool ok; var probing = DataContext as ProbingViewModel; if ((ok = probing.IsSuccess)) { probing.GotoMachinePosition(probing.StartPosition, AxisFlags.Z); probing.GotoMachinePosition(probing.StartPosition, AxisFlags.X | AxisFlags.Y); if (probing.HeightMap.SetToolOffset) { if (probing.CoordinateMode == ProbingViewModel.CoordMode.G10) { probing.Grbl.ExecuteCommand(string.Format("G10L2P{0}Z{1}", probing.CoordinateSystem, (probing.Positions[0].Z - probing.Grbl.ToolOffset.Z).ToInvariantString())); } else if ((ok == probing.GotoMachinePosition(probing.Positions[0], AxisFlags.Z))) { probing.Grbl.ExecuteCommand("G92Z0"); probing.GotoMachinePosition(probing.StartPosition, AxisFlags.Z); if (!probing.Grbl.IsParserStateLive) { probing.Grbl.ExecuteCommand("$G"); } } } double Z0 = probing.Positions[0].Z, z_min = 0d, z_max = 0d, z_delta; foreach (var pos in probing.Positions) { z_delta = pos.Z - Z0; z_min = Math.Min(z_min, z_delta); z_max = Math.Max(z_max, z_delta); probing.HeightMap.Map.AddPoint(toIndex(pos.X - probing.StartPosition.X), toIndex(pos.Y - probing.StartPosition.Y), Math.Round(z_delta, probing.Grbl.Precision)); } LinesVisual3D boundary = new LinesVisual3D(); PointsVisual3D mapPoints = new PointsVisual3D(); MeshGeometryVisual3D mesh = new MeshGeometryVisual3D(); // TODO: fix HeightMap object... probing.HeightMap.Map.GetModel(mesh); probing.HeightMap.Map.GetPreviewModel(boundary, mapPoints); probing.HeightMap.MeshGeometry = mesh.MeshGeometry; probing.HeightMap.BoundaryPoints = boundary.Points; probing.HeightMap.MapPoints = mapPoints.Points; probing.HeightMap.HasHeightMap = true; probing.Program.End(ok ? string.Format("Probing completed: Z min: {0}, Z max: {1}", z_min.ToInvariantString(probing.Grbl.Format), z_max.ToInvariantString(probing.Grbl.Format)) : "Probing failed"); } }
private void DrawDataTip(Point3D nearPnt, Vector3D normal) { PointsVisual3D pntVisual = new PointsVisual3D(); pntVisual.Points.Add(nearPnt); pntVisual.Color = Colors.Black; pntVisual.Size = 10.0; pntVisual.DepthOffset = 0.0001; _dataPointTip.Children.Add(pntVisual); _ptToolTip.Visibility = Visibility.Visible; _ptToolTip.Point = nearPnt; _ptToolTip.AttachedVisual = _curveModel; }
private void Probing_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) { switch (e.PropertyName) { case nameof(ProbingViewModel.IsCompleted): bool ok = true; var probing = DataContext as ProbingViewModel; probing.PropertyChanged -= Probing_PropertyChanged; if (probing.IsSuccess) { probing.GotoMachinePosition(origin, AxisFlags.Z); probing.GotoMachinePosition(origin, AxisFlags.X | AxisFlags.Y); if (probing.HeightMap.SetToolOffset) { if ((ok == probing.GotoMachinePosition(probing.Positions[0], AxisFlags.Z))) { probing.Grbl.ExecuteCommand("G92Z0"); probing.GotoMachinePosition(origin, AxisFlags.Z); } } double Z0 = probing.Positions[0].Z; foreach (var pos in probing.Positions) { probing.HeightMap.Map.AddPoint(toIndex(pos.X - origin.X), toIndex(pos.Y - origin.Y), Math.Round(pos.Z - Z0, probing.Grbl.Precision)); } LinesVisual3D boundary = new LinesVisual3D(); PointsVisual3D mapPoints = new PointsVisual3D(); MeshGeometryVisual3D mesh = new MeshGeometryVisual3D(); // TODO: fix HeightMap object... probing.HeightMap.Map.GetModel(mesh); probing.HeightMap.Map.GetPreviewModel(boundary, mapPoints); probing.HeightMap.MeshGeometry = mesh.MeshGeometry; probing.HeightMap.BoundaryPoints = boundary.Points; probing.HeightMap.MapPoints = mapPoints.Points; probing.HeightMap.HasHeightMap = true; probing.Program.End(ok ? "Probing completed" : "Probing failed"); } origin = null; break; } }
public Sequence(Color color) { Path = new LinesVisual3D { Color = color, Thickness = 3.0, }; Points = new PointsVisual3D() { Color = color, Size = 6.0, }; }
void __gen() { pv3 = new PointsVisual3D() { Color = Colors.White, Size = 2 }; Point3DCollection p3d = null; DispatcherTimer timer = new DispatcherTimer(); #if !DEBUG int counter = 0; #endif timer.Tick += (a, b) => { #if DEBUG p3d = new Point3DCollection(w.CreateWave()); View.Children.Remove(pv3); pv3.Points = p3d; View.Children.Add(pv3); #else if (lps.Playing) { if (counter < 5 && counter != 0) { p3d = new Point3DCollection(Desend(pv3.Points.GetEnumerator())); View.Children.Remove(pv3); pv3.Points = p3d; View.Children.Add(pv3); } else if (counter >= 5) { counter = 0; } if (counter == 0) { p3d = new Point3DCollection(w.CreateWave()); View.Children.Remove(pv3); pv3.Points = p3d; View.Children.Add(pv3); } counter++; } #endif }; timer.Interval = TimeSpan.FromMilliseconds(35d); timer.Start(); }
private void OnCompleted() { bool ok; var probing = DataContext as ProbingViewModel; if ((ok = probing.IsSuccess)) { probing.GotoMachinePosition(origin, AxisFlags.Z); probing.GotoMachinePosition(origin, AxisFlags.X | AxisFlags.Y); if (probing.HeightMap.SetToolOffset) { if (probing.CoordinateMode == ProbingViewModel.CoordMode.G10) { probing.Grbl.ExecuteCommand(string.Format("G10L2P{0}Z{1}", probing.CoordinateSystem, (probing.Positions[0].Z - probing.Grbl.ToolOffset.Z).ToInvariantString())); } else if ((ok == probing.GotoMachinePosition(probing.Positions[0], AxisFlags.Z))) { probing.Grbl.ExecuteCommand("G92Z0"); probing.GotoMachinePosition(origin, AxisFlags.Z); } } double Z0 = probing.Positions[0].Z; foreach (var pos in probing.Positions) { probing.HeightMap.Map.AddPoint(toIndex(pos.X - origin.X), toIndex(pos.Y - origin.Y), Math.Round(pos.Z - Z0, probing.Grbl.Precision)); } LinesVisual3D boundary = new LinesVisual3D(); PointsVisual3D mapPoints = new PointsVisual3D(); MeshGeometryVisual3D mesh = new MeshGeometryVisual3D(); // TODO: fix HeightMap object... probing.HeightMap.Map.GetModel(mesh); probing.HeightMap.Map.GetPreviewModel(boundary, mapPoints); probing.HeightMap.MeshGeometry = mesh.MeshGeometry; probing.HeightMap.BoundaryPoints = boundary.Points; probing.HeightMap.MapPoints = mapPoints.Points; probing.HeightMap.HasHeightMap = true; probing.Program.End(ok ? "Probing completed" : "Probing failed"); } origin = null; }
public void Draw() { //3D Drawing BillboardTextVisual3D txt1; LinesVisual3D linesVisual; PointsVisual3D pointsVisual; Point3DCollection pts = new Point3DCollection(); View1.Children.Clear(); foreach (HeadLossCalc i in lstHeadLossCalcs) { Point3D p1 = new Point3D(i.Node1.X, i.Node1.Y, i.Node1.Z); pts.Add(p1); Point3D p2 = new Point3D(i.Node2.X, i.Node2.Y, i.Node2.Z); pts.Add(p2); txt1 = new BillboardTextVisual3D(); txt1.Text = i.ElementId.ToString(); txt1.Position = new Point3D((i.Node1.X + i.Node2.X) / 2, (i.Node1.Y + i.Node2.Y) / 2, (i.Node1.Z + i.Node2.Z) / 2); View1.Children.Add(txt1); } GridLinesVisual3D grid = new GridLinesVisual3D(); grid.Length = 50000; grid.Width = 50000; grid.MajorDistance = 10000; grid.MinorDistance = 1000; grid.Visible = true; grid.Thickness = 10; View1.Children.Add(grid); pointsVisual = new PointsVisual3D { Color = Colors.Red, Size = 4 }; pointsVisual.Points = pts; View1.Children.Add(pointsVisual); linesVisual = new LinesVisual3D { Color = Colors.Blue }; linesVisual.Points = pts; linesVisual.Thickness = 2; View1.Children.Add(linesVisual); View1.ZoomExtents(10); }
/// <summary> /// Create base scene /// </summary> private void InitializeScene() { WindDirectionScene.Camera = SimulationScene.Camera; cartTrajectoryLines = new LinesVisual3D(); cartTrajectoryLines.Thickness = 3; cartTrajectoryLines.Color = Colors.Blue; cartTrajectoryLines.Points = cartTrajectoryPoints; SimulationScene.Children.Add(cartTrajectoryLines); pendulumTrajectoryLines = new LinesVisual3D(); pendulumTrajectoryLines.Thickness = 3; pendulumTrajectoryLines.Color = Colors.Gold; pendulumTrajectoryLines.Points = pendulumTrajectoryPoints; SimulationScene.Children.Add(pendulumTrajectoryLines); targetTrajectoryLines = new LinesVisual3D(); targetTrajectoryLines.Thickness = 3; targetTrajectoryLines.Color = Colors.Red; targetTrajectoryLines.Points = targetTrajectoryPoints; targetTrajectoryCheckPoints = new PointsVisual3D(); targetTrajectoryCheckPoints.Color = Colors.Purple; targetTrajectoryCheckPoints.Size = 5; targetTrajectoryCheckPoints.Points = targetTrajectoryPoints; simulationArea = new SimulationArea(); SimulationScene.Children.Add(simulationArea.Model); models.Add(simulationArea); cart = new Cart(); SimulationScene.Children.Add(cart.Model); models.Add(cart); pendulum = new Pendulum(); SimulationScene.Children.Add(pendulum.Model); models.Add(pendulum); }
/// <summary> /// /// </summary> /// <param name="path"></param> private void RealPointShow(string path = "") { if (path == "") { path = AppDomain.CurrentDomain.BaseDirectory + "scan/board.pcd"; //点云数据 } ReadP3DTxt.ReadTxtPoint3DsOutZoom(ref rpListReal, path, 13, 6, out Point3D pCenter); //ReadP3DTxt.ReadTxtPoint3Ds(ref rpListReal, path, 13, 6); vp.CameraController.CameraTarget = pCenter; //PCDReader<PointXYZ> reader = new PCDReader<PointXYZ>(); //PointCloud<PointXYZ> pCloud = reader.Read(path); Point3D pCenterTmp = new Point3D(); pCenterTmp.X = 0; pCenterTmp.Y = 4500; pCenterTmp.Z = 0; vp.Camera.Position = pCenterTmp; vp.Camera.LookDirection = new Vector3D(0, -4501, 0); vp.Camera.UpDirection = new Vector3D(0, 0, -1); //显示模型 if (!vp.Children.Contains(pointsVisualReal)) { this.pointsVisualReal = new PointsVisual3D { Color = Colors.Yellow, Size = 2 }; vp.Children.Add(this.pointsVisualReal); } //this.pointsVisualReal.Size = 2; this.PointsReal = new Point3DCollection(GeneratePointsReal()); this.pointsVisualReal.Points = this.PointsReal; }
static void UpdateColor(Visual3D v3d, bool isClicked) { DiffuseMaterial material = isClicked ? PropertyServer.SelectedMaterial : PropertyServer.UnSelectedMaterial; DiffuseMaterial materialBack = isClicked ? PropertyServer.SelectedMaterialBack : PropertyServer.UnSelectedMaterialBack; System.Windows.Media.Color color = isClicked ? PropertyServer.SelectedColor : PropertyServer.UnSelectedColor; if (v3d is MeshVisual3D) { MeshVisual3D mesh = v3d as MeshVisual3D; mesh.FaceMaterial = material; mesh.FaceBackMaterial = materialBack; mesh.EdgeMaterial = material; mesh.VertexMaterial = material; } else if (v3d is LinesVisual3D) { LinesVisual3D line = v3d as LinesVisual3D; line.Color = color; } else if (v3d is PointsVisual3D) { PointsVisual3D pnts = v3d as PointsVisual3D; pnts.Color = color; } else if (v3d is SphereVisual3D) { SphereVisual3D sphere = v3d as SphereVisual3D; sphere.Material = material; } else { Logger.Log(v3d, "NOTYPE"); } }
private void viewPort3d_MouseMove(object sender, System.Windows.Input.MouseEventArgs e) { var Hits = Viewport3DHelper.FindHits(viewPort3d.Viewport, e.GetPosition(viewPort3d.Viewport)); if (Hits.Count > 0) { var FirstHit = Hits[0].Visual; { if (FirstHit is PointsVisual3D) { if (FirstHit != LastPoint3D) { if (LastPoint3D != null) { LastPoint3D.Color = Colors.White; } LastPoint3D = FirstHit as PointsVisual3D; LastPoint3D.Color = Colors.LightGreen; return; } else { return; } } } } // If no valid points were found, set the last point's color to white if (LastPoint3D != null) { LastPoint3D.Color = Colors.White; LastPoint3D = null; } }
void OnCompositionTargetRendering(object sender, EventArgs e) { if (ShowLinesVisual3D && lines == null) { lines = new LinesVisual3D { Color = Colors.Blue }; view1.Children.Add(lines); } if (!ShowLinesVisual3D && lines != null) { lines.IsRendering = false; view1.Children.Remove(lines); lines = null; } if (ShowPointsVisual3D && points == null) { points = new PointsVisual3D { Color = Colors.Red, Size = 6 }; view1.Children.Add(points); } if (!ShowPointsVisual3D && points != null) { points.IsRendering = false; view1.Children.Remove(points); points = null; } if (ShowScreenSpaceLines3D && screenSpaceLines == null) { screenSpaceLines = new ScreenSpaceLines3D { Color = Colors.Green }; view1.Children.Add(screenSpaceLines); } if (!ShowScreenSpaceLines3D && screenSpaceLines != null) { view1.Children.Remove(screenSpaceLines); screenSpaceLines = null; } if (ShowWireLines && wireLines == null) { wireLines = new WireLines { Color = Colors.Pink }; view1.Children.Add(wireLines); } if (!ShowWireLines && wireLines != null) { view1.Children.Remove(wireLines); wireLines = null; } if (Points == null || Points.Count != N || isAnimating) { Points = GeneratePoints(N, watch.ElapsedMilliseconds * 0.001); RaisePropertyChanged("Points"); } if (lines != null) { lines.Points = Points; } if (points != null) { points.Points = Points; } if (screenSpaceLines != null) { screenSpaceLines.Points = Points; } if (wireLines != null) { wireLines.Lines = Points; } }
/// <summary> /// Shows vertex paths. Assumes paths are closed. /// </summary> /// <param name="vertices">The vertices.</param> /// <param name="colors">The colors.</param> /// <param name="ts">The ts.</param> public static void ShowGaussSphereWithIntensity(IList <Vertex> vertices, IList <Color> colors, TessellatedSolid ts) { var window = new Window3DPlot(); var pt0 = new Point3D(ts.Center[0], ts.Center[1], ts.Center[2]); var x = ts.XMax - ts.XMin; var y = ts.YMax - ts.YMin; var z = ts.ZMax - ts.ZMin; var radius = System.Math.Max(System.Math.Max(x, y), z) / 2; //Add the solid to the visual var model = MakeModelVisual3D(ts); window.view1.Children.Add(model); //Add a transparent unit sphere to the visual var sphere = new SphereVisual3D(); sphere.Radius = radius; sphere.Center = pt0; sphere.Material = MaterialHelper.CreateMaterial(new System.Windows.Media.Color { A = 15, R = 200, G = 200, B = 200 }); //window.view1.Children.Add(sphere); var i = 0; foreach (var point in vertices) { var color = colors[i]; var pt1 = new Point3D(pt0.X + point.X * radius, pt0.Y + point.Y * radius, pt0.Z + point.Z * radius); //No create a line collection by doubling up the points var lineCollection = new List <Point3D>(); lineCollection.Add(pt0); lineCollection.Add(pt1); var systemColor = new System.Windows.Media.Color(); systemColor.A = 255; systemColor.R = color.R; systemColor.G = color.G; systemColor.B = color.B; var lines = new LinesVisual3D { Points = new Point3DCollection(lineCollection), Color = systemColor, Thickness = 5 }; var pointsVisual = new PointsVisual3D { Color = systemColor, Size = 5 }; pointsVisual.Points = new Point3DCollection() { pt1 }; window.view1.Children.Add(pointsVisual); window.view1.Children.Add(lines); i++; } window.view1.FitView(window.view1.Camera.LookDirection, window.view1.Camera.UpDirection); window.ShowDialog(); }
public override void SetupCustomUIElements(object ui) { var nodeUI = ui as dynNodeView; MenuItem mi = new MenuItem(); mi.Header = "Zoom to Fit"; mi.Click += new RoutedEventHandler(mi_Click); nodeUI.MainContextMenu.Items.Add(mi); //take out the left and right margins and make this so it's not so wide //NodeUI.inputGrid.Margin = new Thickness(10, 10, 10, 10); //add a 3D viewport to the input grid //http://helixtoolkit.codeplex.com/wikipage?title=HelixViewport3D&referringTitle=Documentation _watchView = new WatchView(); _watchView.watch_view.DataContext = this; RenderOptions.SetEdgeMode(_watchView, EdgeMode.Unspecified); Points = new Point3DCollection(); Lines = new Point3DCollection(); _points = new PointsVisual3D { Color = Colors.Red, Size = 6 }; _lines = new LinesVisual3D { Color = Colors.Blue, Thickness = 1 }; _points.Points = Points; _lines.Points = Lines; _watchView.watch_view.Children.Add(_lines); _watchView.watch_view.Children.Add(_points); _watchView.watch_view.Children.Add(new DefaultLights()); _watchView.Width = 400; _watchView.Height = 300; System.Windows.Shapes.Rectangle backgroundRect = new System.Windows.Shapes.Rectangle(); backgroundRect.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch; backgroundRect.VerticalAlignment = System.Windows.VerticalAlignment.Stretch; //backgroundRect.RadiusX = 10; //backgroundRect.RadiusY = 10; backgroundRect.IsHitTestVisible = false; BrushConverter bc = new BrushConverter(); Brush strokeBrush = (Brush)bc.ConvertFrom("#313131"); backgroundRect.Stroke = strokeBrush; backgroundRect.StrokeThickness = 1; SolidColorBrush backgroundBrush = new SolidColorBrush(System.Windows.Media.Color.FromRgb(250, 250, 216)); backgroundRect.Fill = backgroundBrush; nodeUI.grid.Children.Add(backgroundRect); nodeUI.grid.Children.Add(_watchView); backgroundRect.SetValue(Grid.RowProperty, 2); backgroundRect.SetValue(Grid.ColumnSpanProperty, 3); _watchView.SetValue(Grid.RowProperty, 2); _watchView.SetValue(Grid.ColumnSpanProperty, 3); _watchView.Margin = new Thickness(5, 0, 5, 5); backgroundRect.Margin = new Thickness(5, 0, 5, 5); CompositionTarget.Rendering += new EventHandler(CompositionTarget_Rendering); }
public static void GetPreviewModel(Vector2 min, Vector2 max, int pointsX, int pointsY, LinesVisual3D border, PointsVisual3D pointv) { Vector2 min_temp = new Vector2(Math.Min(min.X, max.X), Math.Min(min.Y, max.Y)); Vector2 max_temp = new Vector2(Math.Max(min.X, max.X), Math.Max(min.Y, max.Y)); min = min_temp; max = max_temp; double gridX = (max.X - min.X) / (pointsX - 1); double gridY = (max.Y - min.Y) / (pointsY - 1); Point3DCollection points = new Point3DCollection(); for (int x = 0; x < pointsX; x++) { for (int y = 0; y < pointsY; y++) { points.Add(new Point3D(min.X + x * gridX, min.Y + y * gridY, 0)); } } pointv.Points.Clear(); pointv.Points = points; Point3DCollection b = new Point3DCollection(); b.Add(new Point3D(min.X, min.Y, 0)); b.Add(new Point3D(min.X, max.Y, 0)); b.Add(new Point3D(min.X, max.Y, 0)); b.Add(new Point3D(max.X, max.Y, 0)); b.Add(new Point3D(max.X, max.Y, 0)); b.Add(new Point3D(max.X, min.Y, 0)); b.Add(new Point3D(max.X, min.Y, 0)); b.Add(new Point3D(min.X, min.Y, 0)); border.Points.Clear(); border.Points = b; }
public static void GetPreviewModel(Vector2 min, Vector2 max, double gridSize, LinesVisual3D border, PointsVisual3D pointv) { Vector2 min_temp = new Vector2(Math.Min(min.X, max.X), Math.Min(min.Y, max.Y)); Vector2 max_temp = new Vector2(Math.Max(min.X, max.X), Math.Max(min.Y, max.Y)); min = min_temp; max = max_temp; if ((max.X - min.X) == 0 || (max.Y - min.Y) == 0) { pointv.Points.Clear(); border.Points.Clear(); return; } int pointsX = (int)Math.Ceiling((max.X - min.X) / gridSize) + 1; int pointsY = (int)Math.Ceiling((max.Y - min.Y) / gridSize) + 1; GetPreviewModel(min, max, pointsX, pointsY, border, pointv); }
public void GetPreviewModel(LinesVisual3D border, PointsVisual3D pointv) { GetPreviewModel(Min, Max, SizeX, SizeY, border, pointv); }
void AddFakeVariablesDebug() { dg_Variables.BeginningEdit -= dg_Variables_BeginningEdit; dg_Variables.BeginningEdit += dg_Variables_BeginningEdit_DEBUG; // datagrid objs DataGridObject obj = new DataGridObject() { Name = "Points" }; DataGridObject sphere = new DataGridObject() { Name = "Sphere" }; DataGridObject mesh = new DataGridObject() { Name = "Mesh" }; DataGridObject line = new DataGridObject() { Name = "Line" }; List <DataGridObject> objs = new List <DataGridObject>() { obj, sphere, line, mesh }; dg_Variables.ItemsSource = objs; // pnts PointsVisual3D points = new PointsVisual3D(); Random rand = new Random(); for (int i = 0; i < 10; i++) { Point3D p = new Point3D(rand.NextDouble(), rand.NextDouble(), rand.NextDouble()); points.Points.Add(p); } points.Size = PropertyServer.PointSize; _dict.Add("Points", points); hv.Items.Add(points); // sphere SphereVisual3D sph = new SphereVisual3D() { Center = new Point3D(0, 0, 0), Radius = 0.1, }; _dict.Add("Sphere", sph); hv.Items.Add(sph); // mesh MeshBuilder builder = new MeshBuilder(true, true); builder.AddTriangle(new Point3D(1, 1, 1), new Point3D(2, 2, 4), new Point3D(5, 3, 3)); MeshVisual3D m = new MeshVisual3D() { Mesh = new Mesh3D(builder.Positions, Enumerable.Range(0, builder.Positions.Count)) }; _dict.Add("Mesh", m); hv.Items.Add(m); // line LinesVisual3D l = new LinesVisual3D(); l.Points.Add(new Point3D(4, 5, 7)); l.Points.Add(new Point3D(4, 8, 5)); _dict.Add("Line", l); hv.Items.Add(l); }
private void LoadModel(string Model_Location, bool New_File = true) { LastPoint3D = null; LastModel3D = null; FaceIndex = 0; if (RAMReader != null) { RAMReader.Close(); RAMReader = null; } FaceTreeView.Items.Clear(); if (PointsVisual3DList != null) { foreach (PointsVisual3D p in PointsVisual3DList) { if (viewPort3d.Children.Contains(p)) { viewPort3d.Children.Remove(p); } } } PointsVisual3DList = new List <PointsVisual3D>(); Model3DList = new List <GeometryModel3D>(); byte[] Data_Array = File.ReadAllBytes(Model_Location); // Convert to AC_Vectors and Point3Ds LoadVertices(Data_Array); /*ModelPoints.Color = Colors.White; * ModelPoints.Points = PointCollection; * ModelPoints.Size = 10;*/ // Generate 3D Model From Points string File_Name = Path.GetFileNameWithoutExtension(Model_Location); if (File_Name.Substring(File_Name.Length - 2, 2).Equals("_v") && Model_Select_Dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { File_Name = Model_Select_Dialog.FileName; if (!File_Name.ToLower().Contains("model")) { return; } string Model_Path = File_Name; if (File.Exists(Model_Path)) { byte[] Model_Data = File.ReadAllBytes(Model_Path); ModelGroup = new Model3DGroup(); ModelParser.ParseModel(Model_Data, Points, this); ModelVisualizer.Content = ModelGroup; viewPort3d.ZoomExtents(); } else { MessageBox.Show(Model_Path); } } else { MessageBox.Show("Couldn't find the _model file!"); } }
private void OnCompositionTargetRendering(object sender, EventArgs e) { if (this.ShowLinesVisual3D && this.linesVisual == null) { this.linesVisual = new LinesVisual3D { Color = Colors.Blue }; View1.Children.Add(this.linesVisual); } if (!this.ShowLinesVisual3D && this.linesVisual != null) { this.linesVisual.IsRendering = false; View1.Children.Remove(this.linesVisual); this.linesVisual = null; } if (this.ShowPointsVisual3D && this.pointsVisual == null) { this.pointsVisual = new PointsVisual3D { Color = Colors.Red, Size = 6 }; View1.Children.Add(this.pointsVisual); } if (!this.ShowPointsVisual3D && this.pointsVisual != null) { this.pointsVisual.IsRendering = false; View1.Children.Remove(this.pointsVisual); this.pointsVisual = null; } if (this.ShowScreenSpaceLines3D && this.screenSpaceLines == null) { this.screenSpaceLines = new ScreenSpaceLines3D { Color = Colors.Green }; View1.Children.Add(this.screenSpaceLines); } if (!this.ShowScreenSpaceLines3D && this.screenSpaceLines != null) { View1.Children.Remove(this.screenSpaceLines); this.screenSpaceLines = null; } if (this.ShowWireLines && this.wireLines == null) { this.wireLines = new WireLines { Color = Colors.Pink }; View1.Children.Add(this.wireLines); } if (!this.ShowWireLines && this.wireLines != null) { View1.Children.Remove(this.wireLines); this.wireLines = null; } if (this.Points == null || this.Points.Count != this.NumberOfPoints) { this.Points = new Point3DCollection(GeneratePoints(this.NumberOfPoints, this.watch.ElapsedMilliseconds * 0.001)); } if (this.linesVisual != null) { this.linesVisual.Points = this.Points; this.linesVisual.Transform = IsMirrored ? new ScaleTransform3D(-1, 1, 1) : new ScaleTransform3D(1, 1, 1); } if (this.pointsVisual != null) { this.pointsVisual.Points = this.Points; this.pointsVisual.Transform = IsMirrored ? new ScaleTransform3D(-1, 1, 1) : new ScaleTransform3D(1, 1, 1); } if (this.screenSpaceLines != null) { this.screenSpaceLines.Points = this.Points; this.screenSpaceLines.Transform = IsMirrored ? new ScaleTransform3D(-1, 1, 1) : new ScaleTransform3D(1, 1, 1); } if (this.wireLines != null) { this.wireLines.Lines = this.Points; this.wireLines.Transform = IsMirrored ? new ScaleTransform3D(-1, 1, 1) : new ScaleTransform3D(1, 1, 1); } }