public void Validate() { Nodes.ForEach(x => x.Validate()); Edges.ForEach(x => x.Validate()); if (Nodes.Select(x => x.Name).Distinct().Count() < Nodes.Count) { throw new ValidationException("Node family names must be unique"); } if (Edges.Select(x => x.Name).Distinct().Count() < Edges.Count) { throw new ValidationException("Edge family names must be unique"); } foreach (var edgeFamily in Edges) { var sourceNode = Nodes.FirstOrDefault(x => x.Name.Equals(edgeFamily.Source.NodeFamilyName)); if (sourceNode == null) { throw new ValidationException($"Cannot define a source of edge family {edgeFamily.Name}: node family with name {edgeFamily.Source.NodeFamilyName} doesn't exist"); } var targetNode = Nodes.FirstOrDefault(x => x.Name.Equals(edgeFamily.Target.NodeFamilyName)); if (targetNode == null) { throw new ValidationException($"Cannot define a target of edge family {edgeFamily.Name}: node family with name {edgeFamily.Target.NodeFamilyName} doesn't exist"); } TwoSetsEquals(edgeFamily.Source.NamesWithTemplates.Keys.ToList(), sourceNode.Ranges.Select(x => x.Name).ToList(), $"Source indices in edge family {edgeFamily.Name} differ with indices of node family {sourceNode.Name}"); TwoSetsEquals(edgeFamily.Target.NamesWithTemplates.Keys.ToList(), targetNode.Ranges.Select(x => x.Name).ToList(), $"Target indices in edge family {edgeFamily.Name} differ with indices of node family {targetNode.Name}"); } }
private void generarXML() { WriteHeader(); Nodos.ForEach(x => WriteNode(x)); Edges.ForEach(x => WriteEdge(x)); xml.WriteEndDocument(); xml.Close(); }
public void TraverseTopDown(Action <N, E, N> fn) { Edges.ForEach(edge => { fn(Label, edge.Label, edge.Target.Label); edge.Target.TraverseTopDown(fn); }); }
internal void OnDeserialized(StreamingContext context) { Edges.ForEach(e => e.Brep = this); Loops.ForEach(l => l.Brep = this); Trims.ForEach(t => t.Brep = this); Faces.ForEach(f => f.Brep = this); //TODO: all the data props to the real props }
public string GetDotString() { StringBuilder sb = new StringBuilder(); Nodes.ForEach(x => sb.Append(x.GetDotString())); Edges.ForEach(x => sb.Append(x.GetDotString())); RankNodes.ForEach(x => sb.Append(x.GetDotString())); return(sb.ToString()); }
public void Write() { using (StreamWriter sw = new StreamWriter(@"C:\Evolver\fe\roice\test.fe")) { sw.WriteLine("vertices"); Vertices.ForEach(v => sw.WriteLine(v.Write())); sw.WriteLine(string.Empty); sw.WriteLine("edges"); Edges.ForEach(e => sw.WriteLine(e.Write())); sw.WriteLine(string.Empty); sw.WriteLine("faces"); Faces.ForEach(f => sw.WriteLine(f.Write() + " density 0")); //Faces.ForEach( f => sw.WriteLine( f.Write() ) ); sw.WriteLine(string.Empty); sw.WriteLine("bodies"); sw.Write("1 "); // Always have 1 { string line = ""; int count = 0; foreach (SurfaceFace face in Faces) { if (face.Reverse) { line += "-" + face.Index; } else { line += face.Index; } count++; if (count >= 10) { sw.WriteLine(line + @" \"); line = ""; count = 0; } else { line += " "; } } sw.Write(line); //sw.Write( line += "volume 1" ); } sw.WriteLine(string.Empty); } }
/// <summary> /// Refreshes reachspecs after one has been removed from this node. /// </summary> public void RefreshConnectionsAfterReachspecRemoval(List <PathfindingNodeMaster> graphNodes) { var edgesToRemove = new List <PathfindingEditorEdge>(); foreach (PathfindingEditorEdge edge in Edges) { //Remove remote connections if (edge.EndPoints[0] != this && edge.EndPoints[0] is PathfindingNode pn0) { var removed = pn0.Edges.Remove(edge); if (removed) { Debug.WriteLine("Removed edge during refresh on endpoint 0"); } } if (edge.EndPoints[1] != this && edge.EndPoints[1] is PathfindingNode pn1) { pn1.Edges.Remove(edge); Debug.WriteLine("Removed edge during refresh on endpoint 1"); } if (edge.IsOneWayOnly()) { edge.Pen.DashStyle = DashStyle.Dash; } else if (!edge.HasAnyOutboundConnections()) { edgesToRemove.Add(edge); } } //Debug.WriteLine("Remaining edges: " + Edges.Count); g.edgeLayer.RemoveChildren(edgesToRemove); //Edges.Clear(); //CreateConnections(graphNodes); Edges.ForEach(PathingGraphEditor.UpdateEdgeStraight); }
private void CheckInvariants() { Edges.ForEach(CheckEdgeInvariants); }