public PositionedShape(ShapeTopography shape, NodeType nodeType) { originalType = nodeType; // initialise nodes nodes = new Vector3[shape.numNodes]; triangles = shape.triangles; intersectors = shape.intersectors; this.nodeTypes = new NodeType[shape.numNodes]; for (int i = 0; i < shape.numNodes; i++) { this.nodeTypes[i] = nodeType; } }
public List <PositionedShape> ToShapes() { if (shapeSpecs.Count == 0) { Debug.LogError("0 shapes specified in problem specification!"); } var shapes = shapeSpecs.Select( s => new PositionedShape( ShapeTopography.FromShapeName(s.shapeName), s.nodeType ) ).ToList(); // generate all posible shape -> node indeces List <int[]> indeces = new List <int[]>(); for (int i = 0; i < shapes.Count; i++) { for (int j = 0; j < shapes[i].nodeTypes.Length; j++) { indeces.Add(new int[] { i, j }); } } // shuffle indeces indeces.Shuffle(); // apply replacements for (int i = 0; i < replacements.numReplacements; i++) { int shapeIndex = indeces[i][0]; int nodeIndex = indeces[i][1]; var shape = shapes[shapeIndex]; shape.nodeTypes[nodeIndex] = replacements.nodeType; } return(shapes); }