/// <summary> /// Transforms a shape by applying a mapping on all its values. /// </summary> public static IInfiniteShape <F> Transform <T, F>(IInfiniteShape <T> Source, Func <T, F> Mapping) { ITransformableInfiniteShape <T> tis = Source.Extend <ITransformableInfiniteShape <T> >(); if (tis != null) { return(tis.Transform <F>(Mapping)); } return(new TransformedInfiniteShape <T, F>() { Source = Source, Mapping = Mapping }); }
/// <summary> /// Gets a subsection of the specified shape. /// </summary> public static IBoundedShape <T> Subsection <T>(IInfiniteShape <T> Source, Vector <int> Size, Vector <int> Start) { IDivisibleInfiniteShape <T> dis = Source.Extend <IDivisibleInfiniteShape <T> >(); if (dis != null) { return(dis.Subsection(Start, Size)); } return(new SubsectionShape <T>() { Source = Source, Start = Start, Size = Size }); }
/// <summary> /// Reorients a shape so that the x axis is transformed to the specified axis. /// </summary> public static IInfiniteShape <T> Orient <T>(IInfiniteShape <T> Source, Axis Axis) { IOrientableInfiniteShape <T> ois = Source.Extend <IOrientableInfiniteShape <T> >(); if (ois != null) { return(ois.Orient(Axis)); } return(new OrientedInfiniteShape <T>() { Source = Source, Axis = Axis }); }
/// <summary> /// Produces a surface using the specified source shape and a surfacization function. /// </summary> public static ISurface <F> Form <T, F>(IInfiniteShape <T> Source, Surfacize <T, F> Surfacization) where F : IEquatable <F> { ISurfaceFormableShape <T> sfs = Source.Extend <ISurfaceFormableShape <T> >(); if (sfs != null) { return(sfs.FormSurface <F>(Surfacization)); } return(new FormSurface <T, F>() { Source = Source, Surfacization = Surfacization }); }