예제 #1
0
        /// <summary>
        /// Checks if the face contains the specified vertex.
        /// </summary>
        /// <param name="v">The vertex to be tested</param>
        /// <returns></returns>
        public bool ContainsVertex(Double2 v)
        {
            int numRoots = 0;

            foreach (var edge in Edges)
            {
                var bbox  = edge.Curve.BoundingBox;
                var lspur = Curve.Line(v, v.WithX(Math.Max(bbox.X + bbox.Width, v.X) + 1f));

                // Ensure we get only one of the endpoints if necessary
                numRoots = unchecked (numRoots + Curve.Intersections(lspur, edge.Curve).Count(p => p.B < 1));
            }
            return(numRoots % 2 == 1);
        }
예제 #2
0
        /// <summary>
        /// Checks if the face contains the specified vertex.
        /// </summary>
        /// <param name="v">The vertex to be tested</param>
        /// <returns></returns>
        public bool ContainsVertex(Double2 v)
        {
            int numRoots = IsOuterFace ? 1 : 0;

            bool HalfOpenRoot(RootPair p) => DoubleUtils.RoughComparer.Compare(p.B, 1) < 0;

            foreach (var edge in Edges)
            {
                // Ignore edges which interface on "blank" contours
                if (edge.Face == edge.Twin.Face)
                {
                    continue;
                }

                var bbox  = edge.Curve.BoundingBox;
                var lspur = Curve.Line(v, v.WithX(Math.Max(bbox.X + bbox.Width, v.X) + 1f));

                // Ensure we get only one of the endpoints if necessary
                numRoots = unchecked (numRoots + Curve.Intersections(lspur, edge.Curve).Count(HalfOpenRoot));
            }
            return(numRoots % 2 == 1);
        }