mirror of
https://github.com/eliasstepanik/OSCADSharpDotnet7.git
synced 2026-01-25 12:08:26 +00:00
Added a sphere constructor that takes variables to pre-bind internal values
This commit is contained in:
parent
8fa6a42040
commit
730b54d703
@ -166,5 +166,22 @@ namespace OSCADSharp.UnitTests
|
|||||||
Assert.IsTrue(script.Contains("$fa = angle"));
|
Assert.IsTrue(script.Contains("$fa = angle"));
|
||||||
Assert.IsTrue(script.Contains("$fs = fragSize"));
|
Assert.IsTrue(script.Contains("$fs = fragSize"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void Sphere_CanCreateSphereWithBindingsFromConstructor()
|
||||||
|
{
|
||||||
|
var diam = new Variable("width", Sizes.OneInch);
|
||||||
|
var resolution = new Variable("rez", 100);
|
||||||
|
|
||||||
|
var sphere = new Sphere(diam, resolution);
|
||||||
|
|
||||||
|
Assert.AreEqual(diam.Value, sphere.Diameter);
|
||||||
|
Assert.AreEqual(resolution.Value, sphere.Resolution);
|
||||||
|
|
||||||
|
string script = sphere.ToString();
|
||||||
|
|
||||||
|
Assert.IsTrue(script.Contains("d = width"));
|
||||||
|
Assert.IsTrue(script.Contains("$fn = rez"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -65,6 +65,25 @@ namespace OSCADSharp.Solids
|
|||||||
{
|
{
|
||||||
this.Diameter = diameter;
|
this.Diameter = diameter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Creates a sphere with one more more pre-bound properties
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="diameter"></param>
|
||||||
|
/// <param name="resolution"></param>
|
||||||
|
/// <param name="minimumAngle"></param>
|
||||||
|
/// <param name="minimumFragmentSize"></param>
|
||||||
|
public Sphere(Variable diameter = null, Variable resolution = null, Variable minimumAngle = null, Variable minimumFragmentSize = null)
|
||||||
|
{
|
||||||
|
if (diameter != null)
|
||||||
|
this.Bind("diameter", diameter);
|
||||||
|
if (resolution != null)
|
||||||
|
this.Bind("resolution", resolution);
|
||||||
|
if (minimumAngle != null)
|
||||||
|
this.Bind("minimumangle", minimumAngle);
|
||||||
|
if (minimumFragmentSize != null)
|
||||||
|
this.Bind("minimumfragmentsize", minimumFragmentSize);
|
||||||
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Overrides
|
#region Overrides
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user