mirror of
https://github.com/eliasstepanik/OSCADSharpDotnet7.git
synced 2026-01-13 22:48:33 +00:00
Shifted code in .ToString of sphere to SphereScriptBuilder
This commit is contained in:
parent
4ecf664db5
commit
16d59a1a19
@ -0,0 +1,44 @@
|
||||
using OSCADSharp.Bindings;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace OSCADSharp.Scripting.Solids
|
||||
{
|
||||
internal class SphereScriptBuilder
|
||||
{
|
||||
private IBindings bindings;
|
||||
private Sphere sphere;
|
||||
|
||||
public SphereScriptBuilder(IBindings bindings, Sphere sphere)
|
||||
{
|
||||
this.bindings = bindings;
|
||||
this.sphere = sphere;
|
||||
}
|
||||
|
||||
internal string GetScript()
|
||||
{
|
||||
StatementBuilder sb = new StatementBuilder(this.bindings);
|
||||
sb.Append("sphere(");
|
||||
|
||||
if (this.bindings.Contains("d"))
|
||||
{
|
||||
sb.AppendValuePairIfExists("d", this.sphere.Diameter);
|
||||
}
|
||||
else
|
||||
{
|
||||
sb.AppendValuePairIfExists("r", this.sphere.Radius);
|
||||
}
|
||||
|
||||
sb.AppendValuePairIfExists("$fn", this.sphere.Resolution, true);
|
||||
sb.AppendValuePairIfExists("$fa", this.sphere.MinimumAngle, true);
|
||||
sb.AppendValuePairIfExists("$fs", this.sphere.MinimumFragmentSize, true);
|
||||
sb.Append(");");
|
||||
sb.Append(Environment.NewLine);
|
||||
|
||||
return sb.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -46,6 +46,7 @@
|
||||
<Compile Include="Internal\Bindings\IBindings.cs" />
|
||||
<Compile Include="Internal\Bindings\Solids\SphereBindings.cs" />
|
||||
<Compile Include="Internal\ICloneable.cs" />
|
||||
<Compile Include="Internal\Scripting\Solids\SphereScriptBuilder.cs" />
|
||||
<Compile Include="Internal\Scripting\VariableCalculator.cs" />
|
||||
<Compile Include="Internal\Scripting\CompoundVariable.cs" />
|
||||
<Compile Include="Public\Settings\Dependencies.cs" />
|
||||
|
||||
@ -9,6 +9,7 @@ using System.Collections.Concurrent;
|
||||
using System.Reflection;
|
||||
using OSCADSharp.Bindings;
|
||||
using OSCADSharp.Bindings.Solids;
|
||||
using OSCADSharp.Scripting.Solids;
|
||||
|
||||
namespace OSCADSharp
|
||||
{
|
||||
@ -90,25 +91,8 @@ namespace OSCADSharp
|
||||
/// <returns>Script for this object</returns>
|
||||
public override string ToString()
|
||||
{
|
||||
StatementBuilder sb = new StatementBuilder(this.bindings);
|
||||
sb.Append("sphere(");
|
||||
|
||||
if (this.bindings.Contains("d"))
|
||||
{
|
||||
sb.AppendValuePairIfExists("d", this.Diameter);
|
||||
}
|
||||
else
|
||||
{
|
||||
sb.AppendValuePairIfExists("r", this.Radius);
|
||||
}
|
||||
|
||||
sb.AppendValuePairIfExists("$fn", this.Resolution, true);
|
||||
sb.AppendValuePairIfExists("$fa", this.MinimumAngle, true);
|
||||
sb.AppendValuePairIfExists("$fs", this.MinimumFragmentSize, true);
|
||||
sb.Append(");");
|
||||
sb.Append(Environment.NewLine);
|
||||
|
||||
return sb.ToString();
|
||||
var scriptBuilder = new SphereScriptBuilder(this.bindings, this);
|
||||
return scriptBuilder.GetScript();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user