コード例 #1
0
        /// <summary>
        /// Return a tree that contains 2 trapezoids
        /// </summary>
        /// <param name="segment"></param>
        /// <returns></returns>
        public Node To2Traps(Segment segment)
        {
            // Segment node
            Node root = new SegmentNode(segment);

            // Trapezoid nodes
            Trapezoid higherTrap = new Trapezoid(null, null, Trapezoid.Top, segment);
            Trapezoid lowerTrap = new Trapezoid(null, null, segment, Trapezoid.Bottom);

            Node higherTrapNode = new TrapezoidalNode(higherTrap);
            Node lowerTrapNode = new TrapezoidalNode(lowerTrap);

            root.SetChildren(ref higherTrapNode, ref lowerTrapNode);

            return root;
        }
コード例 #2
0
        /// <summary>
        /// Return a tree that contains 4 trapezoids
        /// </summary>
        /// <param name="segment"></param>
        /// <returns></returns>
        public Node To4Traps(Segment segment)
        {
            // Vertex nodes
            Node root = new VertexNode(segment.LeftVertex);
            Node rightVertexNode = new VertexNode(segment.RightVertex);

            // Segment node
            Node segmentNode = new SegmentNode(segment);

            // Trapezoid nodes
            Trapezoid leftTrap = new Trapezoid(Trapezoid.Leftp, segment.LeftVertex, Trapezoid.Top, Trapezoid.Bottom);
            Trapezoid higherCenterTrap = new Trapezoid(segment.LeftVertex, segment.RightVertex, Trapezoid.Top, segment);
            Trapezoid lowerCenterTrap = new Trapezoid(segment.LeftVertex, segment.RightVertex, segment, Trapezoid.Bottom);
            Trapezoid rightTrap = new Trapezoid(segment.RightVertex, Trapezoid.Rightp, Trapezoid.Top, Trapezoid.Bottom);

            Node leftTrapNode = new TrapezoidalNode(leftTrap);
            Node higherCenterTrapNode = new TrapezoidalNode(higherCenterTrap);
            Node lowerCenterTrapNode = new TrapezoidalNode(lowerCenterTrap);
            Node rightTrapNode = new TrapezoidalNode(rightTrap);

            leftTrap.SetNeighbor(Trapezoid.HigherLeftNeighbor, Trapezoid.LowerLeftNeighbor, higherCenterTrap, lowerCenterTrap);
            leftTrap.Node = leftTrapNode;

            higherCenterTrap.SetNeighbor(leftTrap, leftTrap, rightTrap, rightTrap);
            higherCenterTrap.Node = higherCenterTrapNode;

            lowerCenterTrap.SetNeighbor(leftTrap, leftTrap, rightTrap, rightTrap);
            lowerCenterTrap.Node = lowerCenterTrapNode;

            rightTrap.SetNeighbor(higherCenterTrap, lowerCenterTrap, Trapezoid.HigherRightNeighbor, Trapezoid.LowerRightNeighbor);
            rightTrap.Node = rightTrapNode;

            segmentNode.SetChildren(ref higherCenterTrapNode, ref lowerCenterTrapNode);
            rightVertexNode.SetChildren(ref segmentNode, ref rightTrapNode);
            root.SetChildren(ref leftTrapNode,ref rightVertexNode);

            return root;
        }