static StrutLayoutFactory() { edgeDictionary = new EdgeDictionary(); for (int i = 0; i < lines.GetLength(0); i++) { int pt0 = lines[i, 0]; int pt1 = lines[i, 1]; if (!edgeDictionary.ContainsKey(pt0)) { edgeDictionary[pt0] = new Dictionary <int, Tuple <int, bool> >(); } if (!edgeDictionary.ContainsKey(pt1)) { edgeDictionary[pt1] = new Dictionary <int, Tuple <int, bool> >(); } edgeDictionary[pt0].Add(pt1, new Tuple <int, bool>(i, false)); edgeDictionary[pt1].Add(pt0, new Tuple <int, bool>(i, true)); } }
private void GenerateMesh(IEnumerable <IEdge> keyEdges, bool debug = false) { //Initialize algorithm EdgeDictionary <T> mapping = new EdgeDictionary <T>(); //generate key edges if needed if (keyEdges == null) { List <IEdge> eList = new List <IEdge>(); keyEdges = eList; foreach (var poly in polygons) { foreach (var edge in poly.Edges()) { eList.Add(edge); } } } //add key edges to map foreach (var edge in keyEdges) { mapping.AddKeyEdge(edge); } if (debug) { foreach (var edge in keyEdges) { var map = mapping.Get(edge); } } //add polygons to map foreach (var poly in polygons) { foreach (var edge in poly.Edges()) { mapping.TryAddEntity(edge, poly); } } if (debug) { foreach (var edge in keyEdges) { var map = mapping.Get(edge); } } //link polygons foreach (var edge in keyEdges) { var polys = mapping.Get(edge); foreach (var poly in polys) { foreach (var other in polys) { if ((IPoly)other == (IPoly)poly) { continue; } polyMap[poly].LinkPolygon(edge, polyMap[other]); polyMap[other].LinkPolygon(edge, polyMap[poly]); } } } //LineDictionary<Dictionary<IEdge, T>> edges = new LineDictionary<Dictionary<IEdge, T>>(); ////generate dictinoary from edges //foreach(var poly in polygons) //{ // foreach(var edge in poly.Edges()) // { // AddEdgeToDictionary(edges, poly, edge); // } //} //foreach(var poly in polygons) //{ // CheckPolyForLinks(poly, edges); //} }