internal static void Display(SeperatePoints seperatePoints)
        {
            GraphicsDisplayer.DisplayClosedInterval(seperatePoints.AdvancedPoints.Select(c => c.Point).ToList(), new Pen(Brushes.Red), true);
            var randomValue = new Random().Next(10);

            GraphicsDisplayer.DisplayPoints(seperatePoints.AdvancedPoints.Select(c => c.Point).ToList(), Brushes.Red, randomValue, randomValue);

            GraphicsDisplayerManager.Save(@"E:\WorkingSpace\Outputs\Images\display3.png");
        }
Beispiel #2
0
        /// <summary>
        /// 获得拆分点
        /// </summary>
        /// <returns></returns>
        public SeperatePoints GetFitLines(Line beamLineZ0)
        {
            var intersectLineZ0s = LineZ0s.Where(c => c.VL_IsIntersect(beamLineZ0));
            //这里计算出了裁剪点,但这里是Z0面的交点
            SeperatePoints result = new SeperatePoints();

            foreach (var intersectLineZ0 in intersectLineZ0s)
            {
                var pointZ0s   = intersectLineZ0.VL_GetIntersectedOrContainedPoints(beamLineZ0);
                var orientLine = Lines.First(c => c.GetEndPoint(0).VL_XYEqualTo(intersectLineZ0.GetEndPoint(0)) && c.GetEndPoint(1).VL_XYEqualTo(intersectLineZ0.GetEndPoint(1)));
                result.AdvancedPoints.AddRange(orientLine.VL_GetZLineIntersection(pointZ0s, IsSolid, beamLineZ0));
            }
            ////裁剪点需回归到面板
            //foreach (var point in points)
            //{
            //    var intersectPoint = Points.FirstOrDefault(p => p.XYEqualTo(point));
            //    if (intersectPoint != null)
            //        result.Points.Add(intersectPoint);
            //    else
            //    {
            //        var unboundLine = Line.CreateBound(point, point + new XYZ(0, 0, 1));
            //        unboundLine.MakeUnbound();
            //        IntersectionResultArray faceIntersect;
            //        Face.Intersect(unboundLine, out faceIntersect);
            //        result.Points.Add(faceIntersect.get_Item(0).XYZPoint);
            //    }
            //}
            //result.Points.AddRange(points);
            //result.Points.AddRange(points.Select(c => new XYZ(c.X, c.Y, Points.FirstOrDefault(p => p.XYEqualTo(c)).Z)));
            foreach (var SubOutLine in SubOutLines)
            {
                var coverType = SubOutLine.IsCover(beamLineZ0);
                if (coverType != CoverType.Disjoint)
                {
                    result.AdvancedPoints.AddRange(SubOutLine.GetFitLines(beamLineZ0).AdvancedPoints);
                }
            }
            return(result);
        }
        public static void Display(string path, SeperatePoints lineSeperatePoints, List <LevelOutLines> outLinesCollection)
        {
            var maxX    = (int)outLinesCollection.Max(c => c.OutLines.Max(v => v.Points.Max(b => b.X)));
            var minX    = (int)outLinesCollection.Min(c => c.OutLines.Min(v => v.Points.Min(b => b.X)));
            var maxY    = (int)outLinesCollection.Max(c => c.OutLines.Max(v => v.Points.Max(b => b.Y)));
            var minY    = (int)outLinesCollection.Min(c => c.OutLines.Min(v => v.Points.Min(b => b.Y)));
            var offSetX = -minX;
            var offSetY = -minY;

            GraphicsDisplayer = new GraphicsDisplayer(minX, maxX, minY, maxY);
            foreach (var levelOutLines in outLinesCollection)
            {
                foreach (var outLine in levelOutLines.OutLines)
                {
                    Display(outLine);
                }
            }
            GraphicsDisplayer.DisplayClosedInterval(lineSeperatePoints.AdvancedPoints.Select(c => c.Point).ToList(), new Pen(Brushes.Red), true);
            var randomValue = new Random().Next(10);

            GraphicsDisplayer.DisplayPoints(lineSeperatePoints.AdvancedPoints.Select(c => c.Point).ToList(), Brushes.Red, randomValue, randomValue);
            GraphicsDisplayer.SaveTo(path);
        }
Beispiel #4
0
        ///// <summary>
        ///// 检测轮廓是否相交或包含 有限线段
        ///// </summary>
        ///// <param name="outLine"></param>
        ///// <returns></returns>
        //public bool IsCover(XYZ pointZ0)
        //{
        //    foreach (var subOutLine in OutLines)
        //    {
        //        if (subOutLine.GetContainer(pointZ0) != null)
        //        {
        //            return true;
        //        }
        //    }
        //    return false;
        //}

        /// <summary>
        /// 获得拆分点
        /// </summary>
        /// <returns></returns>
        public SeperatePoints GetFitLines(Line beamLineZ0)
        {
            SeperatePoints fitLines = new SeperatePoints();
            var            p0       = beamLineZ0.GetEndPoint(0);
            var            p1       = beamLineZ0.GetEndPoint(1);

            foreach (var SubOutLine in OutLines)
            {
                var coverType = SubOutLine.IsCover(beamLineZ0);
                if (coverType != CoverType.Disjoint)
                {
                    fitLines.AdvancedPoints.AddRange(SubOutLine.GetFitLines(beamLineZ0).AdvancedPoints);
                }
                //线的端点增加 注意检测是否已存在
                var point = p0;
                if (fitLines.AdvancedPoints.FirstOrDefault(c => c.Point.VL_XYEqualTo(point)) == null)
                {
                    var triangle = SubOutLine.GetContainer(point);
                    if (triangle != null)
                    {
                        var directOutLine = SubOutLine.GetContainedOutLine(point);
                        fitLines.AdvancedPoints.Add(new AdvancedPoint(VLGeometryHelper.GetIntersection(triangle, point, new XYZ(0, 0, 1)), beamLineZ0.Direction, directOutLine.IsSolid));
                    }
                }
                point = p1;
                if (fitLines.AdvancedPoints.FirstOrDefault(c => c.Point.VL_XYEqualTo(point)) == null)
                {
                    var triangle = SubOutLine.GetContainer(point);
                    if (triangle != null)
                    {
                        var directOutLine = SubOutLine.GetContainedOutLine(point);
                        fitLines.AdvancedPoints.Add(new AdvancedPoint(VLGeometryHelper.GetIntersection(triangle, point, new XYZ(0, 0, 1)), beamLineZ0.Direction, directOutLine.IsSolid));
                    }
                }
            }
            return(fitLines);
        }
Beispiel #5
0
        /// <summary>
        /// 多个裁剪集合的整合
        /// </summary>
        /// <param name="beam"></param>
        /// <param name="lines"></param>
        public SeperatePoints Merge(List <SeperatePoints> seperatePointsCollection, AdvancedPoint beamPoint0, AdvancedPoint beamPoint1)
        {
            SeperatePoints dealedPoints = new SeperatePoints();

            if (seperatePointsCollection.Count() == 0)
            {
                return(dealedPoints);
            }

            seperatePointsCollection = seperatePointsCollection.OrderByDescending(c => c.Z).ToList();
            var usingX = seperatePointsCollection.FirstOrDefault().AdvancedPoints[0].Point.Y == seperatePointsCollection.FirstOrDefault().AdvancedPoints[1].Point.Y;

            if (usingX)
            {
                foreach (var seperatePoints in seperatePointsCollection)
                {
                    foreach (var point in seperatePoints.AdvancedPoints.Where(c => c.Point.X > dealedPoints.Max).OrderBy(c => c.Point.X))
                    {
                        dealedPoints.Add(point, point.Point.X);
                    }
                    foreach (var point in seperatePoints.AdvancedPoints.Where(c => c.Point.X < dealedPoints.Min).OrderByDescending(c => c.Point.X))
                    {
                        dealedPoints.Add(point, point.Point.X);
                    }
                }
            }
            else
            {
                foreach (var seperatePoints in seperatePointsCollection)
                {
                    foreach (var point in seperatePoints.AdvancedPoints.Where(c => c.Point.Y > dealedPoints.Max).OrderBy(c => c.Point.Y))
                    {
                        dealedPoints.Add(point, point.Point.Y);
                    }
                    foreach (var point in seperatePoints.AdvancedPoints.Where(c => c.Point.Y < dealedPoints.Min).OrderByDescending(c => c.Point.Y))
                    {
                        dealedPoints.Add(point, point.Point.Y);
                    }
                }
            }
            var directionPoint = beamPoint0;

            if (dealedPoints.AdvancedPoints.FirstOrDefault(c => c.Point.VL_XYEqualTo(directionPoint.Point)) == null)
            {
                if (usingX)
                {
                    dealedPoints.Add(directionPoint, directionPoint.Point.X);
                }
                else
                {
                    dealedPoints.Add(directionPoint, directionPoint.Point.Y);
                }
            }
            directionPoint = beamPoint1;
            if (dealedPoints.AdvancedPoints.FirstOrDefault(c => c.Point.VL_XYEqualTo(directionPoint.Point)) == null)
            {
                if (usingX)
                {
                    dealedPoints.Add(directionPoint, directionPoint.Point.X);
                }
                else
                {
                    dealedPoints.Add(directionPoint, directionPoint.Point.Y);
                }
            }
            return(dealedPoints);
        }