public override bool Equals(Object obj) { //Check for null and compare run-time types. if ((obj == null) || !this.GetType().Equals(obj.GetType())) { return(false); } else { GridTemplate other = (GridTemplate)obj; for (int x = 0; x < pointMask.Length; x++) { for (int y = 0; y < pointMask[0].Length; y++) { for (int z = 0; z < pointMask[0][0].Length; z++) { if (pointMask[x][y][z] != other.pointMask[x][y][z]) { return(false); } } } } return(true); } }
public static List <GridTemplate> GenerateReflections(List <GridTemplate> gridTemplates) { List <GridTemplate> extendedGridTemplates = new List <GridTemplate>(gridTemplates); foreach (var gridTemplate in gridTemplates) { GridTemplate reflection = GridTemplate.Reflect(gridTemplate, Reflection.R1); if (!extendedGridTemplates.Contains(reflection)) { extendedGridTemplates.Add(reflection); } reflection = GridTemplate.Reflect(gridTemplate, Reflection.R2); if (!extendedGridTemplates.Contains(reflection)) { extendedGridTemplates.Add(reflection); } reflection = GridTemplate.Reflect(gridTemplate, Reflection.R3); if (!extendedGridTemplates.Contains(reflection)) { extendedGridTemplates.Add(reflection); } } return(extendedGridTemplates); }
public static GridTemplate Reflect(PointType[][][] pMask, Reflection reflection) { GridTemplate newGridTemplate = new GridTemplate(pMask); PointType tempPointTypePoint; PointType[] tempPointTypeRow; switch (reflection) { case Reflection.R1: for (int y = 0; y < newGridTemplate.pointMask[0].Length; y++) { tempPointTypePoint = newGridTemplate.pointMask[0][y][1]; newGridTemplate.pointMask[0][y][1] = newGridTemplate.pointMask[1][y][0]; newGridTemplate.pointMask[1][y][0] = tempPointTypePoint; tempPointTypePoint = newGridTemplate.pointMask[0][y][2]; newGridTemplate.pointMask[0][y][2] = newGridTemplate.pointMask[2][y][0]; newGridTemplate.pointMask[2][y][0] = tempPointTypePoint; tempPointTypePoint = newGridTemplate.pointMask[1][y][2]; newGridTemplate.pointMask[1][y][2] = newGridTemplate.pointMask[2][y][1]; newGridTemplate.pointMask[2][y][1] = tempPointTypePoint; } break; case Reflection.R2: for (int x = 0; x < newGridTemplate.pointMask[0].Length; x++) { tempPointTypePoint = newGridTemplate.pointMask[x][0][0]; newGridTemplate.pointMask[x][0][0] = newGridTemplate.pointMask[x][2][2]; newGridTemplate.pointMask[x][2][2] = tempPointTypePoint; tempPointTypePoint = newGridTemplate.pointMask[x][0][1]; newGridTemplate.pointMask[x][0][1] = newGridTemplate.pointMask[x][1][2]; newGridTemplate.pointMask[x][1][2] = tempPointTypePoint; tempPointTypePoint = newGridTemplate.pointMask[x][1][0]; newGridTemplate.pointMask[x][1][0] = newGridTemplate.pointMask[x][2][1]; newGridTemplate.pointMask[x][2][1] = tempPointTypePoint; } break; case Reflection.R3: tempPointTypeRow = newGridTemplate.pointMask[0][0]; newGridTemplate.pointMask[0][0] = newGridTemplate.pointMask[2][2]; newGridTemplate.pointMask[2][2] = tempPointTypeRow; tempPointTypeRow = newGridTemplate.pointMask[0][1]; newGridTemplate.pointMask[0][1] = newGridTemplate.pointMask[1][2]; newGridTemplate.pointMask[1][2] = tempPointTypeRow; tempPointTypeRow = newGridTemplate.pointMask[1][0]; newGridTemplate.pointMask[1][0] = newGridTemplate.pointMask[2][1]; newGridTemplate.pointMask[2][1] = tempPointTypeRow; break; } return(newGridTemplate); }
public static GridTemplate MirrorInPlane(GridTemplate other, PlaneEnum plane) { GridTemplate newGridTemplate = new GridTemplate(other.pointMask); switch (plane) { case PlaneEnum.XY: for (int x = 0; x < newGridTemplate.pointMask.Length; x++) { for (int y = 0; y < newGridTemplate.pointMask[0].Length; y++) { PointType tempPointTypePoint = newGridTemplate.pointMask[x][y][0]; newGridTemplate.pointMask[x][y][0] = newGridTemplate.pointMask[x][y][2]; newGridTemplate.pointMask[x][y][2] = tempPointTypePoint; } } break; case PlaneEnum.XZ: for (int x = 0; x < newGridTemplate.pointMask.Length; x++) { PointType[] tempPointTypeRow = newGridTemplate.pointMask[x][0]; newGridTemplate.pointMask[x][0] = newGridTemplate.pointMask[x][2]; newGridTemplate.pointMask[x][2] = tempPointTypeRow; } break; case PlaneEnum.YZ: PointType[][] tempPointTypePlane = newGridTemplate.pointMask[0]; newGridTemplate.pointMask[0] = newGridTemplate.pointMask[2]; newGridTemplate.pointMask[2] = tempPointTypePlane; break; } return(newGridTemplate); }
public static GridTemplate Reflect(GridTemplate other, Reflection reflection) { return(Reflect(other.pointMask, reflection)); }
public GridTemplate(GridTemplate gridTemplate) { CopyPointMask(gridTemplate.pointMask, ref pointMask); }