예제 #1
0
        public static ElementBounds CreateBounds(ElementBoundsSource boundsSource, ElementBoundsProvider boundsProvider, Transform transform, Func <Bounds> automaticAxisAlignedBox, Func <Sphere> automaticSphere)
        {
            var fixedScale    = (boundsSource & ElementBoundsSource.FixedScale) != 0;
            var fixedRotation = (boundsSource & ElementBoundsSource.FixedRotation) != 0;

            switch (boundsSource & ElementBoundsSource.Source)
            {
            case ElementBoundsSource.None:
                return(null);

            case ElementBoundsSource.LocalOrigin:
                return(new LocalOriginBounds());

            case ElementBoundsSource.Automatic:
                if (fixedRotation)
                {
                    goto case ElementBoundsSource.AutomaticAxisAlignedBox;
                }
                goto case ElementBoundsSource.AutomaticSphere;

            case ElementBoundsSource.AutomaticAxisAlignedBox:
                return(AxisAlignedBoxBounds.Create(automaticAxisAlignedBox(), transform, fixedScale));

            case ElementBoundsSource.AutomaticSphere:
                return(SphereBounds.Create(automaticSphere(), transform, fixedScale, fixedRotation));

            case ElementBoundsSource.Manual:
                return((boundsProvider != null) ? boundsProvider.CreateBounds(fixedScale, fixedRotation) : null);

            default:
                throw new NotImplementedException();
            }
        }
예제 #2
0
 public override ElementBounds CreateBounds(bool fixedScale, bool fixedRotation)
 {
     if (fixedRotation == false)
     {
         throw new ArgumentException("Axis aligned box bounds cannot be used with dynamic rotation.");
     }
     return(AxisAlignedBoxBounds.Create(new Bounds(center, size), fixedScale));
 }