示例#1
0
        private void ParsePair(EdgesPair edgesPair, int edgeLength)
        {
            //Get nodes from each edge's pair
            for (int i = 0; i < edgeLength; i++)
            {
                Location Pnode = edgesPair.ParentClusterEdge.NodesLocations[i];
                Location Nnode = edgesPair.NeighborClusterEdge.NodesLocations[i];

                //Check obstacles
                if (edgesPair.Parent.Matrix[Pnode.X, Pnode.Y, Pnode.Z] != 1 &&
                    edgesPair.Neighbor.Matrix[Nnode.X, Nnode.Y, Nnode.Z] != 1)
                {
                    PEntrancesNodes.Add(Pnode);
                    NEntrancesNodes.Add(Nnode);
                }
                else if (PEntrancesNodes.Count == 0)
                {
                    continue;
                }
                else //reach obstacle
                {
                    RunWriter(edgesPair);

                    PEntrancesNodes = new List <Location>();
                    NEntrancesNodes = new List <Location>();
                }
            }

            if (PEntrancesNodes.Count > 0)
            {
                RunWriter(edgesPair);
            }
        }
示例#2
0
        public List <EdgesPair> Build()
        {
            EdgesPair edgesPair = new EdgesPair();

            foreach (Cluster neighbor in Neighbors)
            {
                if ((neighbor.Location.X - Parent.Location.X) < 0)
                {
                    edgesPair = new EdgesPair(Parent, neighbor,
                                              Parent.GetEdge(ClusterEdge.EdgeSide.Left),
                                              neighbor.GetEdge(ClusterEdge.EdgeSide.Right));
                }
                else if ((neighbor.Location.X - Parent.Location.X) > 0)
                {
                    edgesPair = new EdgesPair(Parent, neighbor,
                                              Parent.GetEdge(ClusterEdge.EdgeSide.Right), neighbor.GetEdge(ClusterEdge.EdgeSide.Left));
                }
                else if ((neighbor.Location.Y - Parent.Location.Y) > 0)
                {
                    edgesPair = new EdgesPair(Parent, neighbor,
                                              Parent.GetEdge(ClusterEdge.EdgeSide.Down), neighbor.GetEdge(ClusterEdge.EdgeSide.Up));
                }
                else if ((neighbor.Location.Y - Parent.Location.Y) < 0)
                {
                    edgesPair = new EdgesPair(Parent, neighbor,
                                              Parent.GetEdge(ClusterEdge.EdgeSide.Up), neighbor.GetEdge(ClusterEdge.EdgeSide.Down));
                }

                EdgesPairsList.Add(edgesPair);
            }

            return(EdgesPairsList);
        }
示例#3
0
        private void RunWriter(EdgesPair edgesPair)
        {
            AbstractNodeWriter nodeWtiter =
                new AbstractNodeWriter(edgesPair.Parent, edgesPair.Neighbor, PEntrancesNodes, NEntrancesNodes);

            //nodeWtiter.WriteByCenter();
            nodeWtiter.WriteByEdges();

            VisitedClusterEdges.Add(edgesPair.ParentClusterEdge);
            VisitedClusterEdges.Add(edgesPair.NeighborClusterEdge);
        }