Example #1
0
        }         // protected void InsertUniqueEdge( Edge e )

        /**
         * If either of the GeometryLocations for the existing label is
         * exactly opposite to the one in the labelToMerge,
         * this indicates a dimensional collapse has happened.
         * In this case, convert the label for that Geometry to a Line label
         */
        /* NOT NEEDED?
         * private void CheckDimensionalCollapse(Label labelToMerge, Label existingLabel)
         * {
         * if (existingLabel.isArea() && labelToMerge.isArea()) {
         * for (int i = 0; i < 2; i++) {
         *       if (! labelToMerge.isNull(i)
         *               &&  labelToMerge.getLocation(i, Position.LEFT)  == existingLabel.getLocation(i, Position.RIGHT)
         *               &&  labelToMerge.getLocation(i, Position.RIGHT) == existingLabel.getLocation(i, Position.LEFT) )
         *       {
         *         existingLabel.toLine(i);
         *       }
         * }
         * }
         * }
         */

        /// <summary>
        /// Update the labels for edges according to their depths.
        /// For each edge, the depths are first normalized.
        /// Then, if the depths for the edge are equal,
        /// this edge must have collapsed into a line edge.
        /// If the depths are not equal, update the label
        /// with the locations corresponding to the depths
        /// (i.e. a depth of 0 corresponds to a Location of EXTERIOR,
        /// a depth of 1 corresponds to INTERIOR)
        /// </summary>
        private void ComputeLabelsFromDepths()
        {
            foreach (object obj in _edgeList)
            {
                Edge  e     = (Edge)obj;
                Label lbl   = e.Label;
                Depth depth = e.Depth;

                // Only check edges for which there were duplicates,
                // since these are the only ones which might
                // be the result of dimensional collapses.

                if (!depth.IsNull())
                {
                    depth.Normalize();
                    for (int i = 0; i < 2; i++)
                    {
                        if (!lbl.IsNull(i) && lbl.IsArea() && !depth.IsNull(i))
                        {
                            // if the depths are equal, this edge is the result of
                            // the dimensional collapse of two or more edges.
                            // It has the same location on both sides of the edge,
                            // so it has collapsed to a line.

                            if (depth.GetDelta(i) == 0)
                            {
                                lbl.ToLine(i);
                            }
                            else
                            {
                                // This edge may be the result of a dimensional collapse,
                                // but it still has different locations on both sides.  The
                                // label of the edge must be updated to reflect the resultant
                                // side locations indicated by the depth values.

                                if (depth.IsNull(i, Position.Left))
                                {
                                    throw new InvalidOperationException("Depth of LEFT side has not been initialized");
                                }
                                lbl.SetLocation(i, Position.Left, depth.GetLocation(i, Position.Left));
                                if (depth.IsNull(i, Position.Right))
                                {
                                    throw new InvalidCastException("Depth of RIGHT side has not been initialized");
                                }
                                lbl.SetLocation(i, Position.Right, depth.GetLocation(i, Position.Right));
                            } // else
                        }     // if ( !lbl.IsNull( i ) && lbl.IsArea() && !depth.IsNull( i ) )
                    }         // for ( int i = 0; i < 2; i++ )
                }             // if ( !depth.IsNull() )
            }                 // foreach ( object obj in _edgeList )
        }                     // private void ComputeLabelsFromDepths()
Example #2
0
        /// <summary>
        /// Update the labels for edges according to their depths.
        /// For each edge, the depths are first normalized.
        /// Then, if the depths for the edge are equal,
        /// this edge must have collapsed into a line edge.
        /// If the depths are not equal, update the label
        /// with the locations corresponding to the depths
        /// (i.e. a depth of 0 corresponds to a Location of Exterior,
        /// a depth of 1 corresponds to Interior)
        /// </summary>
        private void ComputeLabelsFromDepths()
        {
            for (IEnumerator it = _edgeList.GetEnumerator(); it.MoveNext();)
            {
                Edge  e     = (Edge)it.Current;
                Label lbl   = e.Label;
                Depth depth = e.Depth;

                /*
                 * Only check edges for which there were duplicates,
                 * since these are the only ones which might
                 * be the result of dimensional collapses.
                 */
                if (!depth.IsNull())
                {
                    depth.Normalize();
                    for (int i = 0; i < 2; i++)
                    {
                        if (!lbl.IsNull(i) && lbl.IsArea() && !depth.IsNull(i))
                        {
                            /*
                             * if the depths are equal, this edge is the result of
                             * the dimensional collapse of two or more edges.
                             * It has the same location on both sides of the edge,
                             * so it has collapsed to a line.
                             */
                            if (depth.GetDelta(i) == 0)
                            {
                                lbl.ToLine(i);
                            }
                            else
                            {
                                /*
                                 * This edge may be the result of a dimensional collapse,
                                 * but it still has different locations on both sides.  The
                                 * label of the edge must be updated to reflect the resultant
                                 * side locations indicated by the depth values.
                                 */
                                Assert.IsTrue(!depth.IsNull(i, PositionType.Left), "depth of Left side has not been initialized");
                                lbl.SetLocation(i, PositionType.Left, depth.GetLocation(i, PositionType.Left));
                                Assert.IsTrue(!depth.IsNull(i, PositionType.Right), "depth of Right side has not been initialized");
                                lbl.SetLocation(i, PositionType.Right, depth.GetLocation(i, PositionType.Right));
                            }
                        }
                    }
                }
            }
        }
Example #3
0
		/// <summary> 
		/// Update the labels for edges according to their depths.
		/// For each edge, the depths are first normalized.
		/// Then, if the depths for the edge are equal,
		/// this edge must have collapsed into a line edge.
		/// If the depths are not equal, update the label
		/// with the locations corresponding to the depths
		/// (i.e. a depth of 0 corresponds to a Location of EXTERIOR,
		/// a depth of 1 corresponds to INTERIOR)
		/// </summary>
		private void ComputeLabelsFromDepths()
		{
			for (IEdgeEnumerator it = edgeList.Iterator(); it.MoveNext(); )
			{
				Edge e    = it.Current;
				Label lbl = e.Label;
				Depth depth = e.Depth;
				// Only check edges for which there were duplicates,
				// since these are the only ones which might
				// be the result of dimensional collapses.
				if (!depth.IsNull())
				{
					depth.Normalize();
					for (int i = 0; i < 2; i++)
					{
						if (!lbl.IsNull(i) && lbl.IsArea() && !depth.IsNull(i))
						{
							// if the depths are equal, this edge is the result of
							// the dimensional collapse of two or more edges.
							// It has the same location on both sides of the edge,
							// so it has collapsed to a line.
							if (depth.GetDelta(i) == 0)
							{
								lbl.ToLine(i);
							}
							else
							{
								// This edge may be the result of a dimensional collapse,
								// but it still has different locations on both sides.  The
								// label of the edge must be updated to reflect the resultant
								// side locations indicated by the depth values.
								Debug.Assert(!depth.IsNull(i, Position.Left), "depth of LEFT side has not been initialized");
								lbl.SetLocation(i, Position.Left, depth.GetLocation(i, Position.Left));
								Debug.Assert(!depth.IsNull(i, Position.Right), "depth of RIGHT side has not been initialized");
								lbl.SetLocation(i, Position.Right, depth.GetLocation(i, Position.Right));
							}
						}
					}
				}
			}
		}