Ejemplo n.º 1
0
        public List <IMSPoint> Detalize()
        {
            if (finder == null)
            {
                return(new List <IMSPoint>());
            }

            List <IMSPoint> mspoints = new List <IMSPoint>();

            IMSPoint mspoint1 = null, mspoint2 = null;
            bool     firstAdded = false;
            Normal   n1 = null, n2 = null;

            for (int i = 0; i < lines.Count; i++)
            {
                int j = i == lines.Count() - 1 ? 0 : i + 1;
                int k = i == 0 ? lines.Count - 1 : i - 1;

                if (firstAdded)
                {
                    mspoint1 = mspoint2;
                    n1       = n2;
                }
                else
                {
                    mspoint1 = GetMSPoint(lines[i], lines[k], ref n1);
                }
                mspoint2 = GetMSPoint(lines[j], lines[i], ref n2);

                if (mspoint1 == null || mspoint2 == null)
                {
                    firstAdded = false;
                    continue;
                }

                mspoints.Add(mspoint1);
                firstAdded = true;
                var vectorK = lines[k].GetPoint1().GetPoint() - lines[k].GetPoint2().GetPoint();
                var vectorI = lines[i].GetPoint1().GetPoint() - lines[i].GetPoint2().GetPoint();
                var vectorJ = lines[j].GetPoint2().GetPoint() - lines[j].GetPoint1().GetPoint();

                var angle1 = Vector.AngleBetween(vectorI, vectorK);
                var angle2 = Vector.AngleBetween(vectorI, vectorJ);

                if (lines[i].GetPoint2().GetPoint() == lines[j].GetPoint1().GetPoint() &&
                    DetailRequired(mspoint1.GetPoint(), mspoint2.GetPoint(), n1, n2))
                {
                    DetalizeChunk(ref mspoints, mspoint1.GetPoint(), mspoint2.GetPoint(), n1, n2,
                                  angle1, angle2);
                }
            }

            return(mspoints);
        }
Ejemplo n.º 2
0
        IMSPoint FindClosestPoint(IEnumerable <IMSPoint> pointList, IMSPoint point)
        {
            int    closestPointIndex = 0;
            double minDistance       = double.MaxValue;

            for (int i = 0; i < pointList.Count(); i++)
            {
                double currentDistance = (point.GetPoint() - pointList.ElementAt(i).GetPoint()).Length;
                if (currentDistance < minDistance &&
                    point.GetPoint() != pointList.ElementAt(i).GetPoint())
                {
                    closestPointIndex = i;
                    minDistance       = currentDistance;
                }
            }
            return(pointList.ElementAt(closestPointIndex));
        }
Ejemplo n.º 3
0
 public static ISegment PointsToMSSegment(IMSPoint begin, IMSPoint end)
 {
     return(new MSSegment(new BezierCurve(), new List <IMSPoint> {
         begin, end
     }));
 }