示例#1
0
        /// <summary>
        /// Gets the side code for a horizontal segment which is incident on a node,
        /// given any one the boundaries incident on the node.
        /// </summary>
        /// <param name="id">The divider we know about (incident on node).</param>
        /// <param name="isStart">True if it's the start of <c>ib</c>.</param>
        /// <param name="od">The divider the returned side refers to</param>
        /// <returns>Side.Left if the segment is to the left of <c>ob</c>, Side.Right
        /// if segment to the right.</returns>
        internal Side GetSide(IDivider id, bool isStart, out IDivider od)
        {
            ConnectionFinder connect = new ConnectionFinder(id, isStart, this);

            od = connect.Next;
            return(connect.IsStart ? Side.Right : Side.Left);
        }
示例#2
0
        /// <summary>
        /// Get the dividers defining a new polygon ring, starting with the specified divider.
        /// </summary>
        /// <param name="start">The first divider for the new ring</param>
        /// <param name="isPolLeft">Is the polygon ring to the left of the divider?</param>
        /// <returns>The dividers making up the new ring</returns>
        List<Face> GetPolygonFaces(IDivider start, bool isPolLeft)
        {
            List<Face> result = new List<Face>(10);

            bool isLeft = isPolLeft;
            IDivider d = start;
            uint nface = 0;

            // Cycle the polygon until we return to the first divider.
            for (; ; )
            {
                // Define the next face
                Face face = new Face(d, isLeft);
                nface++;

                // If we've created quite a few faces (more than you'd expect), confirm there are no duplicate faces.
                if ((nface % 256)==0 && GetDuplicateFace(result)!=null)
                {
                    IDivider bad = GetDuplicateFace(result).Divider;
                    string msg = String.Format("Topology.GetPolygonDividers - Duplicate face from ({0}) to ({1}) [Line {2}]",
                                                bad.From.ToString(), bad.To.ToString(), bad.Line.InternalId);
                    DumpFaces(msg, result);
                    throw new Exception(msg);
                }

                result.Add(face);

                // Get the next divider in the cycle.
                ConnectionFinder connect = new ConnectionFinder();
                if (!connect.Create(d, isLeft))
                    throw new Exception("Cannot find connecting boundary");

                // If we connected to the start of another divider, the polygon is
                // to the right. The end of the next divider means the polygon is
                // to the left.
                isLeft = !connect.IsStart;
                d = connect.Next;

                // Break out of loop if we have come back to the first divider.
                if (d==start && isLeft==isPolLeft)
                    break;
            }

            return result;
        }