mirror of
https://github.com/eliasstepanik/OSCADSharpDotnet7.git
synced 2026-01-22 10:48:27 +00:00
Reworked Sphere to support binding either Diameter or Radius
This commit is contained in:
parent
0994750fb4
commit
5487af3d95
@ -132,5 +132,21 @@ namespace OSCADSharp.UnitTests
|
|||||||
string script = sphere.ToString();
|
string script = sphere.ToString();
|
||||||
Assert.IsTrue(script.Contains("r = mySphereRadius"));
|
Assert.IsTrue(script.Contains("r = mySphereRadius"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void Sphere_BindingDiameterSetsDiameterInOutput()
|
||||||
|
{
|
||||||
|
string variableName = "diam";
|
||||||
|
double diam = 20;
|
||||||
|
|
||||||
|
Variables.Global.Add(variableName, diam);
|
||||||
|
|
||||||
|
var sphere = new Sphere();
|
||||||
|
sphere.Bind("Diameter", Variables.Global["diam"]);
|
||||||
|
Assert.IsTrue(sphere.Diameter == diam);
|
||||||
|
|
||||||
|
string script = sphere.ToString();
|
||||||
|
Assert.IsTrue(script.Contains("d = diam"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -75,7 +75,16 @@ namespace OSCADSharp.Solids
|
|||||||
{
|
{
|
||||||
StatementBuilder sb = new StatementBuilder(this.bindings);
|
StatementBuilder sb = new StatementBuilder(this.bindings);
|
||||||
sb.Append("sphere(");
|
sb.Append("sphere(");
|
||||||
sb.AppendValuePairIfExists("r", this.Radius);
|
|
||||||
|
if (this.bindings.Contains("d"))
|
||||||
|
{
|
||||||
|
sb.AppendValuePairIfExists("d", this.Diameter);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sb.AppendValuePairIfExists("r", this.Radius);
|
||||||
|
}
|
||||||
|
|
||||||
sb.AppendValuePairIfExists("$fn", this.Resolution, true);
|
sb.AppendValuePairIfExists("$fn", this.Resolution, true);
|
||||||
sb.AppendValuePairIfExists("$fa", this.MinimumAngle, true);
|
sb.AppendValuePairIfExists("$fa", this.MinimumAngle, true);
|
||||||
sb.AppendValuePairIfExists("$fs", this.MinimumFragmentSize, true);
|
sb.AppendValuePairIfExists("$fs", this.MinimumFragmentSize, true);
|
||||||
@ -123,7 +132,11 @@ namespace OSCADSharp.Solids
|
|||||||
|
|
||||||
private Bindings bindings = new Bindings(new Dictionary<string, string>()
|
private Bindings bindings = new Bindings(new Dictionary<string, string>()
|
||||||
{
|
{
|
||||||
{ "radius", "r" }
|
{ "radius", "r" },
|
||||||
|
{ "minimumangle", "$fa" },
|
||||||
|
{ "minimumFragmentsize", "$fs" },
|
||||||
|
{ "resolution", "$fn" },
|
||||||
|
{ "diameter", "d" }
|
||||||
});
|
});
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user