Example #1
0
            public CuboidEnumerator GetNewFromDirection(Direction d)
            {
                CuboidEnumerator result = new CuboidEnumerator(this);

                result.Move(d);
                return(result);
            }
Example #2
0
 public void EnumerateStars()
 {
     for (int w = 1; w < Width - 1; w++)
     {
         for (int h = 1; h < Height - 1; h++)
         {
             for (int d = 1; d < Depth - 1; d++, iterations++)
             {
                 CuboidEnumerator currentPos = new CuboidEnumerator(w, h, d);
                 if (IsStar(currentPos))
                 {
                     colorOccurrences[CharToIndex(this[currentPos])]++;
                     //char current = this[currentPos];
                     //if (stars.ContainsKey(current))
                     //{
                     //    stars[current]++;
                     //}
                     //else
                     //{
                     //    stars.Add(current, 1);
                     //}
                 }
             }
         }
     }
 }
Example #3
0
            public char this[CuboidEnumerator c]
            {
                get
                {
                    return(this[c.WPos, c.HPos, c.DPos]);
                }

                set
                {
                    this[c.WPos, c.HPos, c.DPos] = value;
                }
            }
Example #4
0
 public CuboidEnumerator(CuboidEnumerator c)
 {
     if (c != null)
     {
         WPos = c.WPos;
         HPos = c.HPos;
         DPos = c.DPos;
     }
     else
     {
         throw new System.ArgumentNullException();
     }
 }
Example #5
0
            public bool IsStar(CuboidEnumerator fromPos)
            {
                char currentColor = this[fromPos];

                return(currentColor == this[fromPos.WPos, fromPos.HPos, fromPos.DPos + 1] &&
                       currentColor == this[fromPos.WPos, fromPos.HPos, fromPos.DPos - 1] &&
                       currentColor == this[fromPos.WPos, fromPos.HPos + 1, fromPos.DPos] &&
                       currentColor == this[fromPos.WPos, fromPos.HPos - 1, fromPos.DPos] &&
                       currentColor == this[fromPos.WPos + 1, fromPos.HPos, fromPos.DPos] &&
                       currentColor == this[fromPos.WPos - 1, fromPos.HPos, fromPos.DPos]
                       );
                //return (this[fromPos] == this[fromPos.GetNewFromDirection(Direction.Backward)] &&
                //    this[fromPos] == this[fromPos.GetNewFromDirection(Direction.Forward)] &&
                //    this[fromPos] == this[fromPos.GetNewFromDirection(Direction.Deeper)] &&
                //    this[fromPos] == this[fromPos.GetNewFromDirection(Direction.Shallower)] &&
                //    this[fromPos] == this[fromPos.GetNewFromDirection(Direction.Left)] &&
                //    this[fromPos] == this[fromPos.GetNewFromDirection(Direction.Right)]
                //    );
            }
 public CuboidEnumerator GetNewFromDirection(Direction d)
 {
     CuboidEnumerator result = new CuboidEnumerator(this);
     result.Move(d);
     return result;
 }
 public CuboidEnumerator(CuboidEnumerator c)
 {
     if (c != null)
     {
         WPos = c.WPos;
         HPos = c.HPos;
         DPos = c.DPos;
     }
     else
     {
         throw new System.ArgumentNullException();
     }
 }
 public bool IsStar(CuboidEnumerator fromPos)
 {
     char currentColor = this[fromPos];
     return (currentColor == this[fromPos.WPos, fromPos.HPos, fromPos.DPos + 1] &&
         currentColor == this[fromPos.WPos, fromPos.HPos, fromPos.DPos - 1] &&
         currentColor == this[fromPos.WPos, fromPos.HPos + 1, fromPos.DPos] &&
         currentColor == this[fromPos.WPos, fromPos.HPos - 1, fromPos.DPos] &&
         currentColor == this[fromPos.WPos + 1, fromPos.HPos, fromPos.DPos] &&
         currentColor == this[fromPos.WPos - 1, fromPos.HPos, fromPos.DPos]
         );
     //return (this[fromPos] == this[fromPos.GetNewFromDirection(Direction.Backward)] &&
     //    this[fromPos] == this[fromPos.GetNewFromDirection(Direction.Forward)] &&
     //    this[fromPos] == this[fromPos.GetNewFromDirection(Direction.Deeper)] &&
     //    this[fromPos] == this[fromPos.GetNewFromDirection(Direction.Shallower)] &&
     //    this[fromPos] == this[fromPos.GetNewFromDirection(Direction.Left)] &&
     //    this[fromPos] == this[fromPos.GetNewFromDirection(Direction.Right)]
     //    );
 }
 public void EnumerateStars()
 {
     for (int w = 1; w < Width - 1; w++)
     {
         for (int h = 1; h < Height - 1; h++)
         {
             for (int d = 1; d < Depth - 1; d++, iterations++)
             {
                 CuboidEnumerator currentPos = new CuboidEnumerator(w, h, d);
                 if (IsStar(currentPos))
                 {
                     colorOccurrences[CharToIndex(this[currentPos])]++;
                     //char current = this[currentPos];
                     //if (stars.ContainsKey(current))
                     //{
                     //    stars[current]++;
                     //}
                     //else
                     //{
                     //    stars.Add(current, 1);
                     //}
                 }
             }
         }
     }
 }
            public char this[CuboidEnumerator c]
            {
                get
                {
                    return this[c.WPos, c.HPos, c.DPos];
                }

                set
                {
                    this[c.WPos, c.HPos, c.DPos] = value;
                }
            }