private List <Line> CrossLines(double d) { var lines = new List <Line>(); var nodes = new List <Point3d>(); // Generate nodes CellTools.MakeCornerNodes(ref nodes, d); // Generate struts foreach (int i in (new int[2] { 5, 7 })) { lines.Add(new Line(nodes[0], nodes[i])); lines.Add(new Line(nodes[2], nodes[i])); } foreach (int i in (new int[2] { 4, 6 })) { lines.Add(new Line(nodes[1], nodes[i])); lines.Add(new Line(nodes[3], nodes[i])); } foreach (int i in (new int[4] { 0, 1, 4, 5 })) { lines.Add(new Line(nodes[i], nodes[i + 2])); } return(lines); }
private List <Line> GridLines(double d) { var lines = new List <Line>(); var nodes = new List <Point3d>(); // Generate nodes CellTools.MakeCornerNodes(ref nodes, d); // Generate struts foreach (int i in (new int[3] { 1, 3, 4 })) { lines.Add(new Line(nodes[0], nodes[i])); } foreach (int i in (new int[3] { 1, 3, 6 })) { lines.Add(new Line(nodes[2], nodes[i])); } foreach (int i in (new int[3] { 1, 4, 6 })) { lines.Add(new Line(nodes[5], nodes[i])); } foreach (int i in (new int[3] { 3, 4, 6 })) { lines.Add(new Line(nodes[7], nodes[i])); } return(lines); }
private List <Line> OctetLines(double d) { var lines = new List <Line>(); var nodes = new List <Point3d>(); // Generate nodes CellTools.MakeCornerNodes(ref nodes, d); nodes.Add(new Point3d(d, d / 2, d / 2)); nodes.Add(new Point3d(d / 2, d, d / 2)); nodes.Add(new Point3d(0, d / 2, d / 2)); nodes.Add(new Point3d(d / 2, 0, d / 2)); nodes.Add(new Point3d(d / 2, d / 2, 0)); nodes.Add(new Point3d(d / 2, d / 2, d)); // Generate struts foreach (int i in new int[8] { 0, 1, 2, 3, 8, 9, 10, 11 }) { lines.Add(new Line(nodes[12], nodes[i])); } foreach (int i in new int[8] { 4, 5, 6, 7, 8, 9, 10, 11 }) { lines.Add(new Line(nodes[13], nodes[i])); } foreach (int i in new int[4] { 0, 3, 4, 7 }) { lines.Add(new Line(nodes[10], nodes[i])); } foreach (int i in new int[6] { 2, 3, 6, 7, 8, 10 }) { lines.Add(new Line(nodes[9], nodes[i])); } foreach (int i in new int[4] { 1, 2, 5, 6 }) { lines.Add(new Line(nodes[8], nodes[i])); } foreach (int i in new int[6] { 0, 1, 4, 5, 8, 10 }) { lines.Add(new Line(nodes[11], nodes[i])); } return(lines); }
private List <Line> TesseractLines(double d) { var lines = new List <Line>(); var nodes = new List <Point3d>(); // Generate nodes CellTools.MakeCornerNodes(ref nodes, d); nodes.Add(new Point3d(d / 4, d / 4, d / 4)); nodes.Add(new Point3d(3 * d / 4, d / 4, d / 4)); nodes.Add(new Point3d(3 * d / 4, 3 * d / 4, d / 4)); nodes.Add(new Point3d(d / 4, 3 * d / 4, d / 4)); nodes.Add(new Point3d(d / 4, d / 4, 3 * d / 4)); nodes.Add(new Point3d(3 * d / 4, d / 4, 3 * d / 4)); nodes.Add(new Point3d(3 * d / 4, 3 * d / 4, 3 * d / 4)); nodes.Add(new Point3d(d / 4, 3 * d / 4, 3 * d / 4)); // Generate struts foreach (int i in (new int[3] { 1, 3, 4 })) { lines.Add(new Line(nodes[0], nodes[i])); lines.Add(new Line(nodes[8], nodes[i + 8])); } foreach (int i in (new int[3] { 1, 3, 6 })) { lines.Add(new Line(nodes[2], nodes[i])); lines.Add(new Line(nodes[10], nodes[i + 8])); } foreach (int i in (new int[3] { 1, 4, 6 })) { lines.Add(new Line(nodes[5], nodes[i])); lines.Add(new Line(nodes[13], nodes[i + 8])); } foreach (int i in (new int[3] { 3, 4, 6 })) { lines.Add(new Line(nodes[7], nodes[i])); lines.Add(new Line(nodes[15], nodes[i + 8])); } for (int i = 0; i < 8; i++) { lines.Add(new Line(nodes[i], nodes[i + 8])); } return(lines); }
private List <Line> XLines(double d) { var lines = new List <Line>(); var nodes = new List <Point3d>(); // Generate nodes CellTools.MakeCornerNodes(ref nodes, d); // Generate struts lines.Add(new Line(nodes[0], nodes[6])); lines.Add(new Line(nodes[1], nodes[7])); lines.Add(new Line(nodes[3], nodes[5])); lines.Add(new Line(nodes[2], nodes[4])); return(lines); }
/// <summary> /// Formats the line input into the UnitCell object. It converts the list of lines into /// a list of unique nodes and unique node pairs, ignoring duplicates. /// </summary> private void ExtractTopology(List <Line> lines) { double tol = RhinoDoc.ActiveDoc.ModelAbsoluteTolerance; CellTools.FixIntersections(ref lines); // Iterate through list of lines foreach (Line line in lines) { // Get line, and it's endpoints Point3d[] pts = new Point3d[] { line.From, line.To }; List <int> nodeIndices = new List <int>(); // Loop over end points, being sure to not create the same node twice foreach (Point3d pt in pts) { int closestIndex = this.Nodes.ClosestIndex(pt); // find closest node to current pt // If node already exists if (this.Nodes.Count != 0 && this.Nodes[closestIndex].EpsilonEquals(pt, tol)) { nodeIndices.Add(closestIndex); } // If it doesn't exist, add it else { this.Nodes.Add(pt); nodeIndices.Add(this.Nodes.Count - 1); } } IndexPair nodePair = new IndexPair(nodeIndices[0], nodeIndices[1]); // If not duplicate strut, save it if (this.NodePairs.Count == 0 || !NodePairs.Contains(nodePair)) { this.NodePairs.Add(nodePair); } } }