예제 #1
0
 public void Reset()
 {
     _Map.Reset();
     _SyncContext.Send(d =>
     {
         Model = new Model3DGroup();
         CoordinateSystems.Clear();
     }, null);
 }
예제 #2
0
        public void Render()
        {
            bool showPointCloud         = false;
            bool showKeyFrameTrajectory = false;
            bool showFrameTrajectory    = false;
            bool onlyNew = true;

            _SyncContext.Send(d =>
            {
                showPointCloud         = ShowPointCloud;
                showKeyFrameTrajectory = ShowKeyFrameTrajectory;
                showFrameTrajectory    = ShowFrameTrajectory;
                onlyNew = !(showPointCloud && Model != null && (Model as Model3DGroup).Children.Count == 0);
            }, null);

            if (_Map.HasFrames() || _Map.HasKeyFrames())
            {
                List <Vector3> pointsKeyFrame = new List <Vector3>();
                List <Vector3> pointsFrame    = new List <Vector3>();

                if (showKeyFrameTrajectory)
                {
                    pointsKeyFrame = _Map.GetTrajectory(TrajectoryType.Optimazation);
                }
                if (showFrameTrajectory)
                {
                    pointsFrame = _Map.GetTrajectory(TrajectoryType.PreOptimazation);
                }

                List <GeometryModel3D> pointClouds = new List <GeometryModel3D>();
                if (showPointCloud)
                {
                    pointClouds = _Map.GetPointCloud(onlyNew);
                }

                _SyncContext.Post(d =>
                {
                    TrajectoryKeyFrame = new Point3DCollection(pointsKeyFrame.SelectMany(c => new List <Point3D>()
                    {
                        new Point3D(c.X, c.Y, c.Z), new Point3D(c.X, c.Y, c.Z)
                    }));
                    if (TrajectoryKeyFrame.Count > 0)
                    {
                        TrajectoryKeyFrame.RemoveAt(0);
                    }

                    TrajectoryFrame = new Point3DCollection(pointsFrame.SelectMany(c => new List <Point3D>()
                    {
                        new Point3D(c.X, c.Y, c.Z), new Point3D(c.X, c.Y, c.Z)
                    }));
                    if (TrajectoryFrame.Count > 0)
                    {
                        TrajectoryFrame.RemoveAt(0);
                    }

                    CameraPosition = new MatrixTransform3D(_Map.LastTransformation().Matrix3D);

                    if (Model == null || !showPointCloud)
                    {
                        Model = new Model3DGroup();
                    }
                    foreach (GeometryModel3D pointCloud in pointClouds)
                    {
                        (Model as Model3DGroup).Children.Add(pointCloud);
                    }

                    if (ShowKeyFrameOrientations)
                    {
                        foreach (Visual3D visual3D in _Map.GetKeyFrameOrientations(CoordinateSystems.Count != 0))
                        {
                            CoordinateSystems.Add(visual3D);
                        }
                    }
                    else
                    {
                        CoordinateSystems.Clear();
                    }
                }, null);
            }
            else
            {
                _SyncContext.Post(d =>
                {
                    if (TrajectoryFrame != null && TrajectoryFrame.Count > 0)
                    {
                        TrajectoryFrame = new Point3DCollection();
                    }
                    if (TrajectoryKeyFrame != null && TrajectoryKeyFrame.Count > 0)
                    {
                        TrajectoryKeyFrame = new Point3DCollection();
                    }
                }, null);
            }
        }