mirror of
https://github.com/eliasstepanik/OSCADSharpDotnet7.git
synced 2026-01-25 12:08:26 +00:00
+ Parameterized bindings for Translate
This commit is contained in:
parent
534bba1408
commit
627d60c314
@ -35,5 +35,17 @@ namespace OSCADSharp.UnitTests.Transforms
|
|||||||
string script = cube.ToString();
|
string script = cube.ToString();
|
||||||
Assert.IsTrue(script.Contains("v = vec"));
|
Assert.IsTrue(script.Contains("v = vec"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void Translate_CanBindVectorsByParameters()
|
||||||
|
{
|
||||||
|
var y = new Variable("yAmt", -35);
|
||||||
|
var z = new Variable("zAmt", 40);
|
||||||
|
|
||||||
|
var cube = new Cube().Translate(-5, y, z);
|
||||||
|
|
||||||
|
string script = cube.ToString();
|
||||||
|
Assert.IsTrue(script.Contains("v = [-5, yAmt, zAmt]"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -534,6 +534,7 @@ namespace OSCADSharp
|
|||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region Translate
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Translates an object by the specified amount
|
/// Translates an object by the specified amount
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -544,6 +545,16 @@ namespace OSCADSharp
|
|||||||
return new TranslatedObject(this, translation);
|
return new TranslatedObject(this, translation);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Translates an object by the specified amount with a variable
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="translation">The vector upon which to translate (move object(s))</param>
|
||||||
|
/// <returns>A translated object</returns>
|
||||||
|
public OSCADObject Translate(Variable translation)
|
||||||
|
{
|
||||||
|
return new TranslatedObject(this, translation);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Translates an object by the specified amount
|
/// Translates an object by the specified amount
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -556,6 +567,92 @@ namespace OSCADSharp
|
|||||||
return this.Translate(new Vector3(x, y, z));
|
return this.Translate(new Vector3(x, y, z));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Translates an object by the specified amount with one or more variables
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="x"></param>
|
||||||
|
/// <param name="y"></param>
|
||||||
|
/// <param name="z"></param>
|
||||||
|
/// <returns>A translated object</returns>
|
||||||
|
public OSCADObject Translate(Variable x, Variable y, Variable z)
|
||||||
|
{
|
||||||
|
return new TranslatedObject(this, new Vector3(), x, y, z);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Translates an object by the specified amount with one or more variables
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="x"></param>
|
||||||
|
/// <param name="y"></param>
|
||||||
|
/// <param name="z"></param>
|
||||||
|
/// <returns>A translated object</returns>
|
||||||
|
public OSCADObject Translate(Variable x, double y, double z)
|
||||||
|
{
|
||||||
|
return new TranslatedObject(this, new Vector3(0, y, z), x, null, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Translates an object by the specified amount with one or more variables
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="x"></param>
|
||||||
|
/// <param name="y"></param>
|
||||||
|
/// <param name="z"></param>
|
||||||
|
/// <returns>A translated object</returns>
|
||||||
|
public OSCADObject Translate(double x, Variable y, double z)
|
||||||
|
{
|
||||||
|
return new TranslatedObject(this, new Vector3(x, 0, z), null, y, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Translates an object by the specified amount with one or more variables
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="x"></param>
|
||||||
|
/// <param name="y"></param>
|
||||||
|
/// <param name="z"></param>
|
||||||
|
/// <returns>A translated object</returns>
|
||||||
|
public OSCADObject Translate(double x, double y, Variable z)
|
||||||
|
{
|
||||||
|
return new TranslatedObject(this, new Vector3(x, y, 0), null, null, z);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Translates an object by the specified amount with one or more variables
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="x"></param>
|
||||||
|
/// <param name="y"></param>
|
||||||
|
/// <param name="z"></param>
|
||||||
|
/// <returns>A translated object</returns>
|
||||||
|
public OSCADObject Translate(Variable x, double y, Variable z)
|
||||||
|
{
|
||||||
|
return new TranslatedObject(this, new Vector3(0, y, 0), x, null, z);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Translates an object by the specified amount with one or more variables
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="x"></param>
|
||||||
|
/// <param name="y"></param>
|
||||||
|
/// <param name="z"></param>
|
||||||
|
/// <returns>A translated object</returns>
|
||||||
|
public OSCADObject Translate(double x, Variable y, Variable z)
|
||||||
|
{
|
||||||
|
return new TranslatedObject(this, new Vector3(x, 0, 0), null, y, z);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Translates an object by the specified amount with one or more variables
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="x"></param>
|
||||||
|
/// <param name="y"></param>
|
||||||
|
/// <param name="z"></param>
|
||||||
|
/// <returns>A translated object</returns>
|
||||||
|
public OSCADObject Translate(Variable x, Variable y, double z)
|
||||||
|
{
|
||||||
|
return new TranslatedObject(this, new Vector3(0, 0, z), x, y, null);
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Minkowski/Hull
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a minkowski sum of child nodes (including this object)
|
/// Creates a minkowski sum of child nodes (including this object)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -577,6 +674,8 @@ namespace OSCADSharp
|
|||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
#region Boolean Operations
|
#region Boolean Operations
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a union of all its child nodes. This is the sum of all children (logical or).
|
/// Creates a union of all its child nodes. This is the sum of all children (logical or).
|
||||||
|
|||||||
@ -26,6 +26,23 @@ namespace OSCADSharp.Transforms
|
|||||||
this.Vector = new BindableVector(vector);
|
this.Vector = new BindableVector(vector);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal TranslatedObject(OSCADObject obj, Variable normal) : base(obj)
|
||||||
|
{
|
||||||
|
this.Bind("vector", normal);
|
||||||
|
}
|
||||||
|
|
||||||
|
internal TranslatedObject(OSCADObject obj, Vector3 vector, Variable x, Variable y, Variable z) : base(obj)
|
||||||
|
{
|
||||||
|
this.Vector = new BindableVector(vector);
|
||||||
|
|
||||||
|
if (x != null)
|
||||||
|
this.Bind("x", x);
|
||||||
|
if (y != null)
|
||||||
|
this.Bind("y", y);
|
||||||
|
if (z != null)
|
||||||
|
this.Bind("z", z);
|
||||||
|
}
|
||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
string translation = this.bindings.Contains("vector") ? this.bindings.Get("vector").BoundVariable.Name : this.Vector.ToString();
|
string translation = this.bindings.Contains("vector") ? this.bindings.Get("vector").BoundVariable.Name : this.Vector.ToString();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user