/// <summary> /// Gets the information allowing to display a rubiks' cube face on the console. /// </summary> /// <param name="faceId">Id of the Rubiks' face that will be displayed.</param> /// <returns>A RubikFaceTextView object containing the lines to display in the console for the requested face.</returns> public RubikFaceTextView GetFaceAsText(string faceId) { var axis = this.Cube.GetAxis(faceId); var blocks = this.Cube.GetBlocksForFace(axis.Vector); RubikFaceTextView faces = new RubikFaceTextView(this.Cube.N); int i = 0; int j = 0; var first = blocks.FirstOrDefault().Position; Plane p = new Plane(axis.Vector, first); var sortedBlocks = blocks.OfType <IPositionnedByCartesian3dVector>().ToList(); sortedBlocks.Sort(new PlanePositionPointComparer(p)); foreach (var block in sortedBlocks.OfType <Block>()) { var face = block.GetBlockFace(axis.Vector); RubikCubeBlockFaceTextView result = new RubikCubeBlockFaceTextView(RowsPerBlockFace, face.Id); result.Append("****"); result.Append("****"); faces[j, i++] = result; if (i >= this.Cube.N) { i = 0; ++j; } } return(faces); }
/// <summary> /// Gets the PlaceHolder for a single face. /// </summary> /// <returns>A RubikFaceTextView object used to replace a Rubiks' cube face when their is no face to display in a grid.</returns> public RubikFaceTextView GetFacePlaceHolder() { RubikFaceTextView faces = new RubikFaceTextView(this.Cube.N); RubikCubeFacePlaceHolder result = new RubikCubeFacePlaceHolder(this.RowsPerBlockFace); for (int i = 0; i < this.Cube.N; ++i) { for (int j = 0; j < this.Cube.N; ++j) { faces[i, j] = result; } } return(faces); }