Filled out remaining block string output for transforms

This commit is contained in:
Mike Smith 2016-02-07 11:17:33 -08:00
parent f585e017c2
commit 64066f81f1
6 changed files with 81 additions and 7 deletions

View File

@ -18,9 +18,9 @@ namespace OSCADSharp.ConsoleTests
};
ColoredObject co = new ColoredObject(cube, "Red");
var evenMoreColors = new ColoredObject(co, "Blue", .5);
var mirror = new RotatedObject(co, new Vector3(0, 90, 0));
Console.WriteLine(evenMoreColors.ToString());
Console.WriteLine(mirror.ToString());
Console.ReadKey();
}
}

View File

@ -17,9 +17,24 @@ namespace OSCADSharp.Transforms
/// </summary>
public Vector3 Normal { get; set; } = new Vector3();
private OSCADObject obj;
/// <summary>
/// Creates an object that's mirrored on a plane
/// </summary>
/// <param name="obj">The object(s) to be mirrored</param>
/// <param name="normal">The normal vector of the plane on the object's origin to mirror upon</param>
public MirroredObject(OSCADObject obj, Vector3 normal)
{
this.obj = obj;
this.Normal = normal;
}
public override string ToString()
{
return String.Format("mirror([{0}, {1}, {2}])", this.Normal.X, this.Normal.Y, this.Normal.Z);
string mirrorCommand = String.Format("mirror([{0}, {1}, {2}])", this.Normal.X, this.Normal.Y, this.Normal.Z);
var formatter = new BlockFormatter(mirrorCommand, this.obj.ToString());
return formatter.ToString();
}
}
}

View File

@ -11,12 +11,29 @@ namespace OSCADSharp.Transforms
/// </summary>
public class ResizedObject
{
/// <summary>
/// Size of the object in terms of X/Y/Z
/// </summary>
public Vector3 Size { get; set; }
private OSCADObject obj;
/// <summary>
/// Creates a resized object
/// </summary>
/// <param name="obj">The object(s) to be resized</param>
/// <param name="size">The size to resize to, in terms of x/y/z dimensions</param>
public ResizedObject(OSCADObject obj, Vector3 size)
{
this.obj = obj;
this.Size = size;
}
public override string ToString()
{
return String.Format("resize([{0}, {1}, {2}])", this.Size.X.ToString(),
string resizeCommand = String.Format("resize([{0}, {1}, {2}])", this.Size.X.ToString(),
this.Size.Y.ToString(), this.Size.Z.ToString());
var formatter = new BlockFormatter(resizeCommand, this.obj.ToString());
return formatter.ToString();
}
}
}

View File

@ -11,12 +11,24 @@ namespace OSCADSharp.Transforms
/// </summary>
public class RotatedObject
{
/// <summary>
/// The angle to rotate, in terms of X/Y/Z euler angles
/// </summary>
public Vector3 Angle { get; set; } = new Vector3();
private OSCADObject obj;
public RotatedObject(OSCADObject obj, Vector3 angle)
{
this.obj = obj;
this.Angle = angle;
}
public override string ToString()
{
return String.Format("rotate([{0}, {1}, {2}])",
string rotateCommand = String.Format("rotate([{0}, {1}, {2}])",
this.Angle.X.ToString(), this.Angle.Y.ToString(), this.Angle.Z.ToString());
var formatter = new BlockFormatter(rotateCommand, this.obj.ToString());
return formatter.ToString();
}
}
}

View File

@ -11,12 +11,29 @@ namespace OSCADSharp.Transforms
/// </summary>
public class ScaledObject
{
/// <summary>
/// The scale factor to be applied
/// </summary>
public Vector3 Scale { get; set; } = new Vector3(1, 1, 1);
private OSCADObject obj;
/// <summary>
/// Creates a scaled object
/// </summary>
/// <param name="obj">Object(s) to be scaled</param>
/// <param name="scale">Scale factor in x/y/z components</param>
public ScaledObject(OSCADObject obj, Vector3 scale)
{
this.obj = obj;
this.Scale = scale;
}
public override string ToString()
{
return String.Format("scale(v = [{0}, {1}, {2}])",
string scaleCommand = String.Format("scale(v = [{0}, {1}, {2}])",
this.Scale.X.ToString(), this.Scale.Y.ToString(), this.Scale.Z.ToString());
var formatter = new BlockFormatter(scaleCommand, this.obj.ToString());
return formatter.ToString();
}
}
}

View File

@ -12,12 +12,25 @@ namespace OSCADSharp.Transforms
public class TranslatedObject
{
public Vector3 Vector { get; set; }
private OSCADObject obj;
/// <summary>
/// Creates a translated object
/// </summary>
/// <param name="obj">Object(s) to translate</param>
/// <param name="vector">Amount to translate by</param>
public TranslatedObject(OSCADObject obj, Vector3 vector)
{
this.obj = obj;
this.Vector = vector;
}
public override string ToString()
{
return String.Format("translate(v = [{0}, {1}, {2}])",
string translateCommmand = String.Format("translate(v = [{0}, {1}, {2}])",
this.Vector.X.ToString(), this.Vector.Y.ToString(), this.Vector.Z.ToString());
var formatter = new BlockFormatter(translateCommmand, this.obj.ToString());
return formatter.ToString();
}
}
}