示例#1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="point">the point has to be on the same line as the container</param>
        /// <returns></returns>
        RBNode <AxisEdgesContainer> GetAxisEdgesContainerNode(Point point)
        {
            var prj = xProjection(point);
            var ret =
                edgeContainersTree.FindFirst(cont => xProjection(cont.Source) >= prj - ApproximateComparer.DistanceEpsilon / 2);

            if (ret != null)
            {
                if (xProjection(ret.Item.Source) <= prj + ApproximateComparer.DistanceEpsilon / 2)
                {
                    return(ret);
                }
            }
            return(null);
        }
        void CloseConesCoveredBySegment(Point leftPoint, Point rightPoint, RbTree <ConeSide> tree)
        {
            RBNode <ConeSide> node = tree.FindFirst(
                s => Point.GetTriangleOrientation(s.Start, s.Start + s.Direction, leftPoint) ==
                TriangleOrientation.Counterclockwise);

            Point x;

            if (node == null || !Point.IntervalIntersectsRay(leftPoint, rightPoint,
                                                             node.Item.Start, node.Item.Direction, out x))
            {
                return;
            }
            var conesToRemove = new List <Cone>();

            do
            {
                conesToRemove.Add(node.Item.Cone);
                node = tree.Next(node);
            } while (node != null && Point.IntervalIntersectsRay(leftPoint, rightPoint,
                                                                 node.Item.Start, node.Item.Direction, out x));


            foreach (Cone cone in conesToRemove)
            {
                RemoveCone(cone);
            }
        }
        void CaseToTheLeftOfLineOrOnLineConeRp(VertexEvent rightVertexEvent, PolylinePoint nextVertex)
        {
            EnqueueEvent(new RightVertexEvent(nextVertex));
            //the obstacle side is inside of the cone
            //we need to create an obstacle left side segment instead of the left cone side
            //                var cone = new Cone(rightVertexEvent.Vertex.Point, this);
            //                var obstacleSideSeg = new BrokenConeSide(cone.Apex, nextVertex, new ConeLeftSide(cone));
            //                cone.LeftSide = obstacleSideSeg;
            //                cone.RightSide = new ConeRightSide(cone);
            //                var rnode = InsertToTree(rightConeSides, cone.RightSide);
            //                LookForIntersectionWithConeRightSide(rnode);
            RBNode <ConeSide> lnode =
                leftConeSides.FindFirst(side => PointIsToTheLeftOfSegment(rightVertexEvent.Site, side));

            FixConeLeftSideIntersections(rightVertexEvent.Vertex, nextVertex, lnode);
            if ((nextVertex.Point - rightVertexEvent.Site) * SweepDirection > ApproximateComparer.DistanceEpsilon)
            {
                InsertRightSide(new RightObstacleSide(rightVertexEvent.Vertex));
            }
        }
示例#4
0
        void FindBeforeAfterV(VisibilityVertex v, RbTree <VisibilityVertex> nodeBoundaryRbTree,
                              out VisibilityVertex beforeV, out VisibilityVertex afterV, Point center)
        {
            Point xDir   = new Point(1, 0);
            var   vAngle = Point.Angle(xDir, v.Point - center);
            var   rNode  = nodeBoundaryRbTree.FindLast(w => Point.Angle(xDir, w.Point - center) <= vAngle);

            beforeV = rNode != null ? rNode.Item : nodeBoundaryRbTree.TreeMaximum().Item;
            rNode   = nodeBoundaryRbTree.FindFirst(w => Point.Angle(xDir, w.Point - center) >= vAngle);
            afterV  = rNode != null ? rNode.Item : nodeBoundaryRbTree.TreeMinimum().Item;
        }
示例#5
0
        internal RBNode <BasicReflectionEvent> FindFirstInRange(Point low, Point high)
        {
            // We only use FindFirstPoint in this routine, to find the first satisfying node,
            // so we don't care that we leave leftovers in it.
            findFirstPoint = low;
            RBNode <BasicReflectionEvent> nextNode = eventTree.FindFirst(findFirstPred);

            if (null != nextNode)
            {
                // It's >= low; is it <= high?
                if (Compare(nextNode.Item.Site, high) <= 0)
                {
                    return(nextNode);
                }
            }
            return(null);
        }
 void FindBeforeAfterV(VisibilityVertex v, RbTree<VisibilityVertex> nodeBoundaryRbTree,
     out VisibilityVertex beforeV, out VisibilityVertex afterV, Point center) {
     Point xDir=new Point(1,0);
     var vAngle = Point.Angle(xDir, v.Point - center);
     var rNode = nodeBoundaryRbTree.FindLast(w => Point.Angle(xDir, w.Point - center) <= vAngle);
     beforeV = rNode!=null? rNode.Item : nodeBoundaryRbTree.TreeMaximum().Item;
     rNode = nodeBoundaryRbTree.FindFirst(w => Point.Angle(xDir, w.Point - center) >= vAngle);
     afterV = rNode != null ? rNode.Item : nodeBoundaryRbTree.TreeMinimum().Item;
 }
 RBNode <ConeSide> FindFirstSegmentInTheRightTreeNotToTheLeftOfVertex(SweepEvent vertexEvent)
 {
     return(rightConeSides.FindFirst(
                s => !VertexIsToTheRightOfSegment(vertexEvent, s)
                ));
 }
        void CloseConesCoveredBySegment(Point leftPoint, Point rightPoint, RbTree<ConeSide> tree) {
            var node = tree.FindFirst(
                s => Point.GetTriangleOrientation(s.Start, s.Start + s.Direction, leftPoint) ==
                     TriangleOrientation.Counterclockwise);

            Point x;
            if (node == null || !Point.IntervalIntersectsRay(leftPoint, rightPoint,
                                                             node.Item.Start, node.Item.Direction, out x))
                return;
            var conesToRemove = new List<Cone>();
            do {
                conesToRemove.Add(node.Item.Cone);
                node = tree.Next(node);
            } while (node != null && Point.IntervalIntersectsRay(leftPoint, rightPoint,
                                                                 node.Item.Start, node.Item.Direction, out x));


            foreach (var cone in conesToRemove)
                RemoveCone(cone);
        }