/// <summary> /// /// </summary> private void Start() { _filter = GetComponent <MeshFilter>(); _renderer = GetComponent <MeshRenderer>(); Status = VertexStatus.Default; // default vertex state }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { if (value is VertexStatus) { VertexStatus vertexStatus = (VertexStatus)value; switch (vertexStatus) { case VertexStatus.Simple: return(Brushes.Gray); case VertexStatus.Marked: return(Brushes.Black); case VertexStatus.GoalState: return(Brushes.Green); case VertexStatus.SelectedToExpand: return(Brushes.Yellow); } } return(null); }
/// <summary> /// Sử dụng các giá trị mặc định /// </summary> public void UseDefaultValue() { Font = new Font( new FontFamily("Arial"), 14, FontStyle.Bold, GraphicsUnit.Point); TextColor = Color.Red; BackgroundColor = Color.LightYellow; BorderColor = Color.Blue; BorderSize = 2; Size = 30; Status = VertexStatus.sFree; Infor = ""; InforFont = new Font( new FontFamily("Arial"), 12, FontStyle.Regular, GraphicsUnit.Point); }
/// <summary> /// 构造函数 /// </summary> public Vertex() { InDegree = OutDegree = 0; Status = VertexStatus.UNDISCOVERED; }
public DisplayGraphVertex(string text, VertexStatus vertexStatus = VertexStatus.Simple) { this.Text = text; this.VertexStatus = vertexStatus; }
public void SetStatus(VertexStatus status) { _vertexStatus = status; }
public Vertex(int x, int y) { this.x = x; this.y = y; this.status = VertexStatus.White; }
public void SetStatus(VertexStatus _status) { status = _status; }
/// <summary> /// Executes the actual algorithm. /// </summary> protected override void DoRun(CancellationToken cancellationToken) { const long INTERSECTION = -1; var vertexCountAtStart = _network.VertexCount; var newEdges = new List <long>(); // > 0 is inside, < 0 outside. var currentShape = new List <Coordinate>(); var edgeEnumerator = _network.GetEdgeEnumerator(); for (uint v = 0; v < _network.VertexCount; v++) { if (v >= vertexCountAtStart) { // all new vertices from now on. break; } if (!edgeEnumerator.MoveTo(v)) { continue; } var fLocation = _network.GetVertex(v); var fLocationInside = _area.Overlaps(fLocation.Latitude, fLocation.Longitude); while (edgeEnumerator.MoveNext()) { // var attributes = _db.GetProfileAndMeta(edgeData.Profile, edgeData.MetaId); // Console.WriteLine(attributes); if (edgeEnumerator.DataInverted) { // consider each edge only once and only in the forward direction. continue; } if (edgeEnumerator.To >= vertexCountAtStart) { // the neighbour is already a new vertex. continue; } var edgeData = edgeEnumerator.Data; newEdges.Clear(); // build status. var hasIntersections = false; Coordinate[] intersections; var tLocation = _network.GetVertex(edgeEnumerator.To); var status = new List <VertexStatus>(new List <Coordinate>().Count); var previous = new VertexStatus() { Location = fLocation, Vertex = v, Inside = fLocationInside }; status.Add(previous); var edgeShape = edgeEnumerator.Shape; if (edgeShape != null) { foreach (var shape in edgeShape) { intersections = _area.Intersect(previous.Location.Latitude, previous.Location.Longitude, shape.Latitude, shape.Longitude); if (intersections != null && intersections.Length > 0) { // intersections where found. hasIntersections = true; foreach (var intersection in intersections) { previous = new VertexStatus() { Location = intersection, Vertex = INTERSECTION, Inside = !previous.Inside }; status.Add(previous); } } previous = new VertexStatus() { Location = shape, Vertex = Itinero.Constants.NO_VERTEX, Inside = previous.Inside }; status.Add(previous); } } // test intersections in the last segment. intersections = _area.Intersect(previous.Location.Latitude, previous.Location.Longitude, tLocation.Latitude, tLocation.Longitude); if (intersections != null && intersections.Length > 0) { // intersections where found. hasIntersections = true; foreach (var intersection in intersections) { previous = new VertexStatus() { Location = intersection, Vertex = INTERSECTION, Inside = !previous.Inside }; status.Add(previous); } } previous = new VertexStatus() { Location = _network.GetVertex(edgeEnumerator.To), Vertex = edgeEnumerator.To, Inside = previous.Inside }; status.Add(previous); // continue to the next edge if nothing is to be done. if (!hasIntersections && !status[0].Inside) { // edge not inside and no intersections. continue; } // handle the easy case, no intersections but inside. if (!hasIntersections && status[0].Inside) { // just update edge meta data. this.EdgeInside?.Invoke(edgeEnumerator.Id); continue; } // loop over all status pairs and if inside do stuff. currentShape.Clear(); newEdges.Clear(); var previousRelevant = status[0]; var previousDistance = 0f; for (var s = 1; s < status.Count; s++) { var current = status[s]; // update distance. previousDistance += Coordinate.DistanceEstimateInMeter(previousRelevant.Location, current.Location); if (current.Vertex == Itinero.Constants.NO_VERTEX) { // just a shape point. currentShape.Add(current.Location); continue; } if (current.Vertex == INTERSECTION) { // this needs to become a new vertex and we need a new edge. // add the new vertex. current.Vertex = _network.VertexCount; _network.AddVertex((uint)current.Vertex, current.Location.Latitude, current.Location.Longitude); this.NewVertex?.Invoke((uint)current.Vertex); } // add the new edge for the segment. var newEdgeData = edgeData; newEdgeData.Distance = previousDistance; if (previousDistance > _network.MaxEdgeDistance) { newEdgeData.Distance = _network.MaxEdgeDistance; } long edgeId = _network.AddEdge((uint)previousRelevant.Vertex, (uint)current.Vertex, newEdgeData, currentShape); if (!previousRelevant.Inside) { edgeId = -edgeId; } newEdges.Add(edgeId); // prepare for the next segment. currentShape.Clear(); previousRelevant = current; previousDistance = 0; } // notify listeners on all new edges now that we still have the old one around. foreach (var newEdgeId in newEdges) { if (newEdgeId < 0) { this.NewEdge?.Invoke(edgeEnumerator.Id, (uint)-newEdgeId); } else { this.NewEdge?.Invoke(edgeEnumerator.Id, (uint)newEdgeId); } } // remove the old edge. _network.RemoveEdge(edgeEnumerator.Id); edgeEnumerator.Reset(); // don't use after this point. edgeEnumerator.MoveTo(v); // notify listeners about the edges inside. foreach (var newEdgeId in newEdges) { if (newEdgeId > 0) { this.EdgeInside?.Invoke((uint)newEdgeId); } } } } this.HasSucceeded = true; }