예제 #1
0
 private void ScaleColors(double min, double max)
 {
     Points.PointsGeometry.Colors = VisualizationTools.ScalePointColors(Points.PointsGeometry.Positions, MaxMinDepth[1], MaxMinDepth[0], min, max, _colorScales);
     if (PointGrid.GridGeometry != null)
     {
         ScaleGridColors(min, max);
     }
 }
예제 #2
0
        public void test()
        {
            var XYZHashMap = GetPointCloud.XYZMap(Filepath);

            var linebuilderGeometry = VisualizationTools.DrawPointGrid(XYZHashMap, MinColorScaleZ, MaxColorScaleZ, _colorScales);

            PointGrid = new GridModel {
                GridGeometry = linebuilderGeometry, GridTransform = new TranslateTransform3D(0, 0, 0), GridColor = new Color4(255, 255, 255, 0.5f).ToColor()
            };
            ScaleColors(MinColorScaleZ, MaxColorScaleZ);
        }
예제 #3
0
        private void ViewPointCloud()
        {
            Clear();
            VisualizationTools.AddPointCloud(_gridPoints, out PointModel points, out GridModel grid, out AxisModel axis,
                                             out HelixToolkit.Wpf.SharpDX.Camera cam, _cameraTypeSwitch);
            this.Camera = cam;
            this.Points = points;
            this.Grid   = grid;
            this.Axis   = axis;

            GetMinMaxZRange();
            ScaleColors(MinColorScaleZ, MaxColorScaleZ);
        }
예제 #4
0
        public static void ClearView(out PointModel Points, out GridModel Grid, out AxisModel Axis)
        {
            // floor plane grid
            var Maxreset = 100;
            var Minreset = -100;

            Points = new PointModel
            {
                // point positions and color gradient
                PointsGeometry = new PointGeometry3D {
                    Positions = new Vector3Collection(), Indices = new IntCollection(), Colors = new Color4Collection()
                },
                PointsColor     = Colors.White,
                PointsTransform = new Media3D.TranslateTransform3D(0, 0, Minreset)
            };

            LineBuilder gridLines = new LineBuilder();

            VisualizationTools.CreateGrid(gridLines, Maxreset, Minreset, Maxreset, Maxreset, Minreset);
            Grid = new GridModel
            {
                GridGeometry  = gridLines.ToLineGeometry3D(),
                GridColor     = new Color4(153 / 255.0f, 204 / 255.0f, 255 / 255.0f, (float)0.3).ToColor(),
                GridTransform = new TranslateTransform3D(0, 0, 0)
            };

            // lines
            LineBuilder arrows = new LineBuilder();

            VisualizationTools.CreateAxes(arrows, Maxreset, Minreset, Maxreset, Minreset, Maxreset, Minreset);
            Axis = new AxisModel
            {
                AxisGeometry  = arrows.ToLineGeometry3D(),
                AxisColor     = new Color4(0, 255 / 255.0f, 255 / 255.0f, (float)0.5).ToColor(),
                AxisTransform = new TranslateTransform3D(0, 0, 0)
            };
        }
예제 #5
0
        public static Color4Collection ScalePointColors(Vector3Collection points, double actualMin, double actualMax, double newMin, double newMax, Enums.colorScales colorScale)
        {
            var temp = new Color4Collection();

            switchColorScale(colorScale);


            foreach (var item in points)
            {
                if (item.Z > (float)newMax)
                {
                    temp.Add(new Color4(VisualizationTools.scaleHolder((float)actualMin, (float)newMax, (float)newMax)));
                }
                else if (item.Z < (float)newMin)
                {
                    temp.Add(new Color4(VisualizationTools.scaleHolder((float)newMin, (float)actualMax, (float)newMin)));
                }
                else
                {
                    temp.Add(new Color4(VisualizationTools.scaleHolder((float)newMin, (float)newMax, item.Z)));
                }
            }
            return(temp);
        }
예제 #6
0
 private void ScaleGridColors(double min, double max)
 {
     PointGrid.GridGeometry.Colors = VisualizationTools.ScaleGridColors(PointGrid.GridGeometry.Lines, min, max, _colorScales);
 }
예제 #7
0
        public static void AddPointCloud(Dictionary <KeyValuePair <int, int>, double> PointCollection, out PointModel Points,
                                         out GridModel Grid, out AxisModel Axis, out HelixToolkit.Wpf.SharpDX.Camera Camera, bool cameraType = false)
        {
            Camera = null;
            Points = null;
            Grid   = null;
            Axis   = null;

            var points = new PointGeometry3D();
            var col    = new Color4Collection();  // color gradient
            var ptPos  = new Vector3Collection(); // point positions
            var ptIdx  = new IntCollection();     // point indexes

            if (PointCollection != null && PointCollection.Count() > 1)
            {
                //newdataFromTxt(path, positionX, positionY, positionZ);
                var maxX    = PointCollection.Max(x => x.Key.Key);   // X
                var minX    = PointCollection.Min(x => x.Key.Key);   // X
                var maxY    = PointCollection.Max(x => x.Key.Value); // Y
                var minY    = PointCollection.Min(x => x.Key.Value); // Y
                var maxZ    = PointCollection.Max(x => x.Value);     // Z
                var minZ    = PointCollection.Min(x => x.Value);     // Z
                var minYObj = PointCollection.First(x => x.Key.Value == minY);

                Trace.WriteLine($"{maxX} {minX} {maxY} {minY} {maxZ} {minZ}");

                if (PointCollection.Count() <= 0)
                {
                    return;
                }
                foreach (var point in PointCollection)
                {
                    var positionToColour = point.Value;

                    ptIdx.Add(ptPos.Count);
                    ptPos.Add(new Vector3((float)point.Key.Key, ((float)point.Key.Value), (float)point.Value));
                    col.Add(new Color4(RedBlueScale((float)minZ, (float)maxZ, (float)positionToColour)));
                }
                Points = new PointModel
                {
                    // indexes and color gradient
                    PointsGeometry = new PointGeometry3D {
                        Positions = ptPos, Indices = ptIdx, Colors = col
                    },
                    PointsColor     = Colors.White,
                    PointsTransform = new TranslateTransform3D(-minX, -minY, -minZ)
                };
                // floor plane grid
                LineBuilder gridLines = new LineBuilder();
                VisualizationTools.CreateGrid(gridLines, maxX, minX, maxY, minY, minZ);
                Grid = new GridModel
                {
                    GridGeometry  = gridLines.ToLineGeometry3D(),
                    GridColor     = new Color4(153 / 255.0f, 204 / 255.0f, 255 / 255.0f, 0.3f).ToColor(),
                    GridTransform = new TranslateTransform3D(0, 0, 0)
                };
                // lines
                LineBuilder arrows = new LineBuilder();
                VisualizationTools.CreateAxes(arrows, (float)maxX, (float)minX, (float)maxY, (float)minY, (float)maxZ, (float)minZ);
                Axis = new AxisModel
                {
                    AxisGeometry  = arrows.ToLineGeometry3D(),
                    AxisColor     = new Color4(0, 255 / 255.0f, 255 / 255.0f, 0.5f).ToColor(),
                    AxisTransform = new TranslateTransform3D(0, 0, 0)
                };

                if (cameraType == false)
                {
                    Camera = new HelixToolkit.Wpf.SharpDX.PerspectiveCamera
                    {
                        Position         = new Point3D(0, 0, Math.Abs(minZ * 100)),
                        LookDirection    = new Vector3D(((float)maxX - (float)minX) / 2, ((float)maxY - (float)minY) / 2, -Math.Abs(minZ * 100)),//z kamerą jest problem przy przybliżaniu prawdopodobnie przez ten LookDirection albo sposób poruszania kamerą
                        UpDirection      = new Vector3D(0, 1, 0),
                        FarPlaneDistance = 5000000
                    };
                }
                else
                {
                    Camera = new HelixToolkit.Wpf.SharpDX.OrthographicCamera
                    {
                        Position         = new Point3D(0, 0, Math.Abs(minZ * 100)),
                        LookDirection    = new Vector3D(((float)maxX - (float)minX) / 2, ((float)maxY - (float)minY) / 2, -Math.Abs(minZ * 100)),//z kamerą jest problem przy przybliżaniu prawdopodobnie przez ten LookDirection albo sposób poruszania kamerą
                        UpDirection      = new Vector3D(0, 1, 0),
                        FarPlaneDistance = 5000000
                    };
                }
            }
        }