ToString methods for solids

This commit is contained in:
Mike Smith 2016-02-07 01:02:03 -08:00
parent ff4da516e5
commit 6288a63fdd
4 changed files with 28 additions and 4 deletions

View File

@ -47,6 +47,9 @@
<Compile Include="Solids\Sphere.cs" /> <Compile Include="Solids\Sphere.cs" />
<Compile Include="Vector3.cs" /> <Compile Include="Vector3.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<Folder Include="Transforms\" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets. Other similar extension points exist, see Microsoft.Common.targets.

View File

@ -24,5 +24,11 @@ namespace OSCADSharp.Solids
/// </summary> /// </summary>
public bool Center { get; set; } = false; public bool Center { get; set; } = false;
#endregion #endregion
public override string ToString()
{
return String.Format("cube(size = [{0}, {1}, {2}], center = {3});",
this.Size.X.ToString(), this.Size.Y.ToString(), this.Size.Z.ToString(), this.Center.ToString().ToLower()); ;
}
} }
} }

View File

@ -95,6 +95,11 @@ namespace OSCADSharp.Solids
public int Resolution { get; set; } = 0; public int Resolution { get; set; } = 0;
#endregion #endregion
public override string ToString()
{
return String.Format("cylinder($fn = {0}, $fa = {1}, $fs = {2}, h = {3}, r1 = {4}, r2 = {5}, center = {6});",
Resolution.ToString(), MinimumAngle.ToString(), MinimumCircumferentialLength.ToString(),
Height.ToString(), Radius1.ToString(), Radius2.ToString(), Center.ToString().ToLower());
}
} }
} }

View File

@ -20,7 +20,10 @@ namespace OSCADSharp.Solids
/// <summary> /// <summary>
/// This is the diameter of the sphere /// This is the diameter of the sphere
/// </summary> /// </summary>
public double Diameter { get; set; } public double Diameter {
get { return this.Radius * 2; }
set { this.Radius = value / 2; }
}
/// <summary> /// <summary>
/// Minimum angle (in degrees) of each cylinder fragment. /// Minimum angle (in degrees) of each cylinder fragment.
@ -29,10 +32,10 @@ namespace OSCADSharp.Solids
public int MinimumAngle { get; set; } = 12; public int MinimumAngle { get; set; } = 12;
/// <summary> /// <summary>
/// Minimum circumferential length of each fragment. /// Fragment size in mm
/// ($fs in OpenSCAD) /// ($fs in OpenSCAD)
/// </summary> /// </summary>
public int MinimumCircumferentialLength { get; set; } = 2; public int MinimumFragmentSize { get; set; } = 2;
/// <summary> /// <summary>
/// Number of fragments in 360 degrees. Values of 3 or more override MinimumAngle and MinimumCircumferentialLength /// Number of fragments in 360 degrees. Values of 3 or more override MinimumAngle and MinimumCircumferentialLength
@ -40,5 +43,12 @@ namespace OSCADSharp.Solids
/// </summary> /// </summary>
public int Resolution { get; set; } = 0; public int Resolution { get; set; } = 0;
#endregion #endregion
public override string ToString()
{
return String.Format("sphere($fn = {0}, $fa = {1}, $fs = {2}, r = {3});",
this.Resolution.ToString(), this.MinimumAngle.ToString(),
this.MinimumFragmentSize.ToString(), this.Radius.ToString());
}
} }
} }