Ejemplo n.º 1
0
        public BranchNode CreateBranchNode(Point2D position)
        {
            BranchNode node = new BranchNode(position);

            branchNodes.Add(node);
            return(node);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Build a dictionary of connected components for the fault network by scanning
        /// the connected component map to determine the number of components, and the
        /// connectivity map to register the free ends and junction points of each connected
        /// component, which will be used as starting points when tracing the components.
        /// </summary>
        private void BuildComponents()
        {
            // Build a List of the starting points for each componentId
            for (int i = 0; i < componentsMap.Width; ++i)
            {
                for (int j = 0; j < componentsMap.Height; ++j)
                {
                    int componentId = componentsMap[i, j];
                    if (componentId != 0)
                    {
                        Component component = ComponentFromId(componentId);

                        int connectivity = connectivityMap[i, j];
                        Debug.Assert(connectivity > 0);
                        switch (connectivity)
                        {
                        case 1:
                            component.freeEnds.Add(new Discrete2D(i, j));
                            break;

                        case 3:
                        case 4:
                            Point2D    geographicPosition = GridToGeographic(i, j);
                            BranchNode branchNode         = network.CreateBranchNode(geographicPosition);
                            component.junctions.Add(new Discrete2D(i, j), branchNode);
                            break;

                        default:
                            break;
                        }
                    }
                }
            }
        }
Ejemplo n.º 3
0
        private Discrete2D?EndSegmentAtJunction(Component component, Discrete2D?current, SegmentNode segment, Discrete2D junction)
        {
            // End segment here with edge to junction
            Debug.Assert(current.HasValue);
            BranchNode branchPoint = component.junctions[junction];
            Point2D    geographic  = GridToGeographic(current.Value.I, current.Value.J);

            segment.Add(geographic);
            segment.NextBranch = branchPoint;
            MarkVisited(current.Value);
            return(null);
        }