Exemple #1
0
        public int GetComponent(CuboidComponents component)
        {
            switch (component)
            {
            case CuboidComponents.Left:
                return(Left);

            case CuboidComponents.Bottom:
                return(Bottom);

            case CuboidComponents.Forward:
                return(Forward);

            case CuboidComponents.Length:
                return(Length);

            case CuboidComponents.Height:
                return(Height);

            case CuboidComponents.Width:
                return(Width);

            default:
                throw new InvalidOperationException("face argument can not use a mix of bit flags and can not be set to None (0). Call SetComponents(Faces,Cuboid) instead.");
            }
        }
Exemple #2
0
        /// <summary>
        /// Assigns the component using the coresponding face
        /// </summary>
        /// <param name="cuboidComponent">The face of the box. Can not use a mix of bit flags</param>
        /// <param name="value">The value to assign</param>
        /// <returns>A new cuboid</returns>
        public Cuboid SetComponent(CuboidComponents cuboidComponent, int value)
        {
            switch (cuboidComponent)
            {
            case CuboidComponents.Left:
                return(new Cuboid(new Point3(value, Bottom, Forward), Dimensions));

            case CuboidComponents.Bottom:
                return(new Cuboid(new Point3(Left, value, Forward), Dimensions));

            case CuboidComponents.Forward:
                return(new Cuboid(new Point3(Left, Bottom, value), Dimensions));

            case CuboidComponents.Length:
                return(new Cuboid(Position, new Point3(value, Height, Width)));

            case CuboidComponents.Height:
                return(new Cuboid(Position, new Point3(Length, value, Width)));

            case CuboidComponents.Width:
                return(new Cuboid(Position, new Point3(Length, Height, value)));

            case CuboidComponents.None:
                return(this);

            default:
                throw new InvalidOperationException("face argument can not use a mix of bit flags. Call SetComponents(Faces,Cuboid) instead");
            }
        }
Exemple #3
0
 /// <summary>
 /// Assigns the components using the coresponding faces
 /// </summary>
 /// <param name="cuboidComponents">The face of the box. Can not use a mix of bit flags</param>
 /// <param name="values">The value to assign</param>
 /// <returns>A new cuboid with a mix of new and original values, based on if each bit-flag of faces was set.</returns>
 public Cuboid SetComponents(CuboidComponents cuboidComponents, Cuboid values)
 {
     return(new Cuboid(
                cuboidComponents.Any(CuboidComponents.Left) ? values.Left : Left,
                cuboidComponents.Any(CuboidComponents.Bottom) ? values.Bottom : Bottom,
                cuboidComponents.Any(CuboidComponents.Forward) ? values.Forward : Forward,
                cuboidComponents.Any(CuboidComponents.Length) ? values.Length : Length,
                cuboidComponents.Any(CuboidComponents.Height) ? values.Height : Height,
                cuboidComponents.Any(CuboidComponents.Width) ? values.Width : Width));
 }
Exemple #4
0
 /// <summary>
 /// Returns if any face bit-flags have been set.
 /// </summary>
 /// <param name="cuboidComponents"></param>
 /// <returns></returns>
 public static bool Any(this CuboidComponents cuboidComponents)
 {
     return((cuboidComponents & All) != 0);
 }
Exemple #5
0
 /// <summary>
 /// Returns if the face and its comparer share any common faces.
 /// </summary>
 /// <param name="a">The first face value</param>
 /// <param name="b">The second face value</param>
 public static bool Any(this CuboidComponents a, CuboidComponents b)
 {
     return((a & b) != 0);
 }
Exemple #6
0
 /// <summary>
 /// Returns if any lengths have been set.
 /// </summary>
 public static bool AnyLengths(this CuboidComponents cuboidComponent)
 {
     return((cuboidComponent & Lengths) != 0);
 }
Exemple #7
0
 /// <summary>
 /// Returns if any face flags have been set.
 /// </summary>
 public static bool AnyFaces(this CuboidComponents cuboidComponent)
 {
     return((cuboidComponent & NegativeFaces) != 0);
 }