예제 #1
0
        private static IRing StitchPaths(this IPath[] paths, EdgeIndices edgeIndices)
        {
            IRing result = new Ring();

            foreach (var edgeIndex in edgeIndices)
            {
                var path = paths[edgeIndex];
                if (path.PointCount == 0)
                {
                    continue;
                }

                if (result.PointCount == 0)
                {
                    result.AddPoints(path.ToArray());
                }
                else
                {
                    var lastPoint = result[result.PointCount - 1];
                    if (lastPoint.Equals(path[0]))
                    {
                        result.AddPoints(path.ToArray(1));
                    }
                    else if (lastPoint.Equals(path[path.PointCount - 1]))
                    {
                        result.AddPoints(path.ToArray(1, true));
                    }
                    else
                    {
                        throw new Exception("Can't stitch path to ring");
                    }
                }
            }

            return(result);
        }