diff --git a/OSCADSharp/OSCADSharp.ConsoleTests/Program.cs b/OSCADSharp/OSCADSharp.ConsoleTests/Program.cs index 8d9a5df..4af8fa6 100644 --- a/OSCADSharp/OSCADSharp.ConsoleTests/Program.cs +++ b/OSCADSharp/OSCADSharp.ConsoleTests/Program.cs @@ -3,27 +3,75 @@ namespace OSCADSharp.ConsoleTests { class Program { + private static OSCADObject getEndCover(OSCADObject outer) + { + var bounds = outer.Bounds(); + var endCover = new Cube(Inches.Sixteenth, bounds.Width, bounds.Height, true); + var choppedOut = endCover.Clone().Scale(2, (bounds.Width-Inches.Quarter)/ bounds.Width, (bounds.Height - Inches.Half) / bounds.Height); + choppedOut = choppedOut.Translate(0, Inches.Quarter, 0); + + return endCover - choppedOut; + } + + private static void makeBracket() + { + OSCADObject cube = new Cube(new Vector3(Inches.ToMillimeters(2.75), Inches.One, Inches.ToMillimeters(1.25)), true); + var outside = cube.Clone(); + ((Cube)outside).Size.X += Inches.Sixteenth; + ((Cube)outside).Size.Z += Inches.Sixteenth; + cube = cube.Scale(2, 1, 1).Translate(0, Inches.Sixteenth, 0); + + var obj = outside - cube; + var bounds = obj.Bounds(); + + obj = obj + getEndCover(outside).Translate(bounds.XMax, 0, 0); + obj = obj + getEndCover(outside).Translate(-bounds.XMax, 0, 0); + + obj.ToFile("leftBracket").Open(); + } + + private static void makePeg() + { + Variables.Global.Add("$fn", 30); + + OSCADObject flatInnerPortion = new Cylinder(Inches.Quarter, Inches.Eigth, true); + OSCADObject shaft = new Cylinder(Inches.Eigth, Inches.Half, true); + flatInnerPortion = flatInnerPortion.Translate(0, 0, shaft.Bounds().ZMax); + + OSCADObject pegShaft = new Cylinder(Inches.Quarter, Inches.Half - Inches.Eigth, true) + .Translate(0, 0, -Inches.Eigth); + OSCADObject bottomBall = new Sphere(Inches.Quarter* 1.1) + .Translate(0, 0, pegShaft.Bounds().ZMin); + + var obj = flatInnerPortion + shaft + pegShaft + bottomBall; + obj = obj.Rotate(0, 180, 0).Translate(0, 0, obj.Bounds().ZMax); + + obj.ToFile("peg"); + } + static void Main(string[] args) { - var diam = new Variable("mainColumn", Inches.Half); - var height = new Variable("overallHeight", Inches.Quarter); - Variables.Global.Add(diam); - Variables.Global.Add(height); + makePeg(); - var cyl = new Cylinder(diam, diam, height); - + //var diam = new Variable("mainColumn", Inches.Half); + //var height = new Variable("overallHeight", Inches.Quarter); + //Variables.Global.Add(diam); + //Variables.Global.Add(height); - var pos = cyl.Position(); - var cyl1 = new Cylinder(1, 100, true).Translate(pos); - var cyl2 = new Cylinder(1, 100, true).Rotate(0, 90, 0).Translate(pos); - var cyl3 = new Cylinder(1, 100, true).Rotate(90, 0, 0).Translate(pos); - var axisHelper = cyl1.Union(cyl2, cyl3).Color("Red"); + //var cyl = new Cylinder(diam, diam, height); - //var topCorner = new Sphere().Translate(obj.Bounds().TopRight); - //var botCorner = new Sphere().Translate(obj.Bounds().BottomLeft); - (cyl + axisHelper).ToFile("test.scad").Open(); - + //var pos = cyl.Position(); + //var cyl1 = new Cylinder(1, 100, true).Translate(pos); + //var cyl2 = new Cylinder(1, 100, true).Rotate(0, 90, 0).Translate(pos); + //var cyl3 = new Cylinder(1, 100, true).Rotate(90, 0, 0).Translate(pos); + //var axisHelper = cyl1.Union(cyl2, cyl3).Color("Red"); + + ////var topCorner = new Sphere().Translate(obj.Bounds().TopRight); + ////var botCorner = new Sphere().Translate(obj.Bounds().BottomLeft); + + //(cyl + axisHelper).ToFile("test.scad").Open(); + //Console.ReadKey(); } } diff --git a/OSCADSharp/OSCADSharp/Internal/Bindings/BindableVector.cs b/OSCADSharp/OSCADSharp/Internal/Bindings/BindableVector.cs index b0fbf8e..c428da3 100644 --- a/OSCADSharp/OSCADSharp/Internal/Bindings/BindableVector.cs +++ b/OSCADSharp/OSCADSharp/Internal/Bindings/BindableVector.cs @@ -15,7 +15,7 @@ namespace OSCADSharp { "z", "z" } }); - public BindableVector(Vector3 vector, Dictionary synonyms = null) : this(vector.X, vector.Y, vector.Z) + internal BindableVector(Vector3 vector, Dictionary synonyms = null) : this(vector.X, vector.Y, vector.Z) { this.X = vector.X; this.Y = vector.Y; @@ -24,7 +24,7 @@ namespace OSCADSharp this.setSynonyms(synonyms); } - public BindableVector(double x = 0, double y = 0, double z = 0, Dictionary synonyms = null) + internal BindableVector(double x = 0, double y = 0, double z = 0, Dictionary synonyms = null) { this.X = x; this.Y = y; @@ -58,7 +58,7 @@ namespace OSCADSharp return String.Format("[{0}, {1}, {2}]", x, y, z); } - public new BindableVector Clone() + internal new BindableVector Clone() { var clone = new BindableVector(base.Clone()); clone.bindings = this.bindings.Clone(); diff --git a/OSCADSharp/OSCADSharp/Internal/Bindings/Bindings.cs b/OSCADSharp/OSCADSharp/Internal/Bindings/Bindings.cs index 107af8c..5ef09e2 100644 --- a/OSCADSharp/OSCADSharp/Internal/Bindings/Bindings.cs +++ b/OSCADSharp/OSCADSharp/Internal/Bindings/Bindings.cs @@ -16,7 +16,7 @@ namespace OSCADSharp #endregion #region Constructors - public Bindings() + internal Bindings() { this.propertyNametoOpenSCADFieldMappings = new Dictionary(); } diff --git a/OSCADSharp/OSCADSharp/Internal/Booleans/Difference.cs b/OSCADSharp/OSCADSharp/Internal/Booleans/Difference.cs index 2a60005..a7a2d89 100644 --- a/OSCADSharp/OSCADSharp/Internal/Booleans/Difference.cs +++ b/OSCADSharp/OSCADSharp/Internal/Booleans/Difference.cs @@ -15,7 +15,7 @@ namespace OSCADSharp /// Creates a subtraction of child nodes /// /// - public Difference(IEnumerable children) : base("difference()", children) + internal Difference(IEnumerable children) : base("difference()", children) { } diff --git a/OSCADSharp/OSCADSharp/Internal/Booleans/Intersection.cs b/OSCADSharp/OSCADSharp/Internal/Booleans/Intersection.cs index 3104686..2001f79 100644 --- a/OSCADSharp/OSCADSharp/Internal/Booleans/Intersection.cs +++ b/OSCADSharp/OSCADSharp/Internal/Booleans/Intersection.cs @@ -15,7 +15,7 @@ namespace OSCADSharp /// Creates the intersection of all child nodes /// /// - public Intersection(IEnumerable children) : base("intersection()", children) + internal Intersection(IEnumerable children) : base("intersection()", children) { } diff --git a/OSCADSharp/OSCADSharp/Internal/Files/DefaultFileInvoker.cs b/OSCADSharp/OSCADSharp/Internal/Files/DefaultFileInvoker.cs index 91c3d31..a6eee75 100644 --- a/OSCADSharp/OSCADSharp/Internal/Files/DefaultFileInvoker.cs +++ b/OSCADSharp/OSCADSharp/Internal/Files/DefaultFileInvoker.cs @@ -10,7 +10,7 @@ namespace OSCADSharp internal class DefaultFileInvoker : IFileInvoker { private readonly string filePath; - public DefaultFileInvoker(string filePath) + internal DefaultFileInvoker(string filePath) { this.filePath = filePath; } diff --git a/OSCADSharp/OSCADSharp/Internal/Scripting/CompoundVariable.cs b/OSCADSharp/OSCADSharp/Internal/Scripting/CompoundVariable.cs index 90e5051..4e1c4b4 100644 --- a/OSCADSharp/OSCADSharp/Internal/Scripting/CompoundVariable.cs +++ b/OSCADSharp/OSCADSharp/Internal/Scripting/CompoundVariable.cs @@ -8,7 +8,7 @@ namespace OSCADSharp { internal class CompoundVariable : Variable { - public CompoundVariable(string name, object value) : base(name, value, false) + internal CompoundVariable(string name, object value) : base(name, value, false) { } } diff --git a/OSCADSharp/OSCADSharp/Internal/Scripting/Solids/SphereScriptBuilder.cs b/OSCADSharp/OSCADSharp/Internal/Scripting/Solids/SphereScriptBuilder.cs index 9d47206..2c779a1 100644 --- a/OSCADSharp/OSCADSharp/Internal/Scripting/Solids/SphereScriptBuilder.cs +++ b/OSCADSharp/OSCADSharp/Internal/Scripting/Solids/SphereScriptBuilder.cs @@ -11,7 +11,7 @@ namespace OSCADSharp private IBindings bindings; private Sphere sphere; - public SphereScriptBuilder(IBindings bindings, Sphere sphere) + internal SphereScriptBuilder(IBindings bindings, Sphere sphere) { this.bindings = bindings; this.sphere = sphere; diff --git a/OSCADSharp/OSCADSharp/Internal/Scripting/StatementBuilder.cs b/OSCADSharp/OSCADSharp/Internal/Scripting/StatementBuilder.cs index da20ff7..9cce110 100644 --- a/OSCADSharp/OSCADSharp/Internal/Scripting/StatementBuilder.cs +++ b/OSCADSharp/OSCADSharp/Internal/Scripting/StatementBuilder.cs @@ -32,7 +32,7 @@ namespace OSCADSharp /// The Name of the value-pair /// The value - if null this method does nothing /// (optional) Flag indicating whether a comma should be added before the value-pair - public void AppendValuePairIfExists(string name, object value, bool prefixWithComma = false) + internal void AppendValuePairIfExists(string name, object value, bool prefixWithComma = false) { bool useBinding = this.shouldUseBinding(name); @@ -68,7 +68,7 @@ namespace OSCADSharp /// Pass-through for StringBuilder.Append /// /// - public void Append(string text) + internal void Append(string text) { SB.Append(text); } diff --git a/OSCADSharp/OSCADSharp/Internal/Transforms/HulledObject.cs b/OSCADSharp/OSCADSharp/Internal/Transforms/HulledObject.cs index a3f69c6..f91335a 100644 --- a/OSCADSharp/OSCADSharp/Internal/Transforms/HulledObject.cs +++ b/OSCADSharp/OSCADSharp/Internal/Transforms/HulledObject.cs @@ -11,7 +11,7 @@ namespace OSCADSharp /// internal class HulledObject : MultiStatementObject { - public HulledObject(IEnumerable children) : base("hull()", children) + internal HulledObject(IEnumerable children) : base("hull()", children) { } } diff --git a/OSCADSharp/OSCADSharp/Internal/Transforms/MinkowskiedObject.cs b/OSCADSharp/OSCADSharp/Internal/Transforms/MinkowskiedObject.cs index c5a2896..3816ed6 100644 --- a/OSCADSharp/OSCADSharp/Internal/Transforms/MinkowskiedObject.cs +++ b/OSCADSharp/OSCADSharp/Internal/Transforms/MinkowskiedObject.cs @@ -12,7 +12,7 @@ namespace OSCADSharp internal class MinkowskiedObject : MultiStatementObject { - public MinkowskiedObject(IEnumerable children) : base("minkowski()", children) + internal MinkowskiedObject(IEnumerable children) : base("minkowski()", children) { } diff --git a/OSCADSharp/OSCADSharp/Public/Inches.cs b/OSCADSharp/OSCADSharp/Public/Inches.cs index 137006f..2dd87f8 100644 --- a/OSCADSharp/OSCADSharp/Public/Inches.cs +++ b/OSCADSharp/OSCADSharp/Public/Inches.cs @@ -9,7 +9,7 @@ namespace OSCADSharp /// /// Constants and conversions for units for us imperial-minded folks. /// - public class Inches + public static class Inches { /// /// One imperial inch