//Add/remove functions public bool AddVertex(Vertex vertex) { //Check if there exists a vertexcollection that could need it for (int i = 0; i < _vertices.Count; i++) { VertexCollection coll = _vertices[i]; if (coll.Contains(vertex.Offset)) { return(false); } else if (coll.IsAdjacentTo(vertex.Offset, Vertex.Size)) { //Add to the collection coll.Vertices.Add(vertex); if (coll.Offset > vertex.Offset) { coll.Offset -= 0x10; } //Do some kind of reverse checking on the collection to make sure it now isn't adacent to another collection for (int j = 0; j < _vertices.Count; j++) { if (i == j) { continue; } if (coll.IsAdjacentTo(_vertices[j].Offset, _vertices[j].Size)) { int newOffset = Math.Min(coll.Offset, _vertices[j].Offset); foreach (Vertex vert in _vertices[j].Vertices) { coll.Vertices.Add(vert); } coll.Offset = newOffset; _vertices.RemoveAt(j); return(true); } } return(true); } } //Create new VertexCollection VertexCollection newColl = new VertexCollection(vertex.Offset); newColl.Vertices.Add(vertex); _vertices.Add(newColl); return(true); }
//Add/remove functions public bool AddVertex(Vertex vertex) { //Check if there exists a vertexcollection that could need it for (int i = 0; i < _vertices.Count; i++) { VertexCollection coll = _vertices[i]; if (coll.Contains(vertex.Offset)) return false; else if (coll.IsAdjacentTo(vertex.Offset, Vertex.Size)) { //Add to the collection coll.Vertices.Add(vertex); if (coll.Offset > vertex.Offset) coll.Offset -= 0x10; //Do some kind of reverse checking on the collection to make sure it now isn't adacent to another collection for (int j = 0; j < _vertices.Count; j++) { if (i == j) continue; if (coll.IsAdjacentTo(_vertices[j].Offset, _vertices[j].Size)) { int newOffset = Math.Min(coll.Offset, _vertices[j].Offset); foreach (Vertex vert in _vertices[j].Vertices) { coll.Vertices.Add(vert); } coll.Offset = newOffset; _vertices.RemoveAt(j); return true; } } return true; } } //Create new VertexCollection VertexCollection newColl = new VertexCollection(vertex.Offset); newColl.Vertices.Add(vertex); _vertices.Add(newColl); return true; }