Example #1
0
        public void Cube_CloneYieldsSameScript()
        {
            var cube = new Cube(new Vector3(1.5, 5.5, 8.7));

            var clone = cube.Clone();

            Assert.IsTrue(clone.IsSameAs(cube));
        }
Example #2
0
        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;
        }
Example #3
0
        public void Mirror_SingleAxisMirrorInvertsPosition()
        {
            var cube = new Cube(5, 10, 20);
            var xMirror = cube.Clone().Mirror(1, 0, 0);
            var yMirror = cube.Clone().Mirror(0, 1, 0);
            var zMirror = cube.Clone().Mirror(0, 0, 1);

            var pos = cube.Position().Clone();
            pos.X = -pos.X;
            Assert.AreEqual(pos, xMirror.Position());

            pos = cube.Position().Clone();
            pos.Y = -pos.Y;
            Assert.AreEqual(pos, yMirror.Position());

            pos = cube.Position().Clone();
            pos.Z = -pos.Z;
            Assert.AreEqual(pos, zMirror.Position());
        }
Example #4
0
        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();
        }
Example #5
0
        private static void makeCardClip()
        {
            var leftSide = new Cube(Inches.Sixteenth, Inches.Half, Inches.Half, true)
                .Rotate(0, -3, 0).Translate(Inches.Sixteenth, 0, Inches.Half / 2);
            var rightSide = leftSide.Clone().Mirror(1, 0, 0);
            var bottom = new Cube(Inches.Quarter*.85, Inches.Half, Inches.Sixteenth, true);

            var obj = leftSide + rightSide + bottom;
            //obj = new Sphere() { Radius = .25, Resolution = 30 }.Translate(0, 0, -1).Minkowski(obj);

            //90 degree joint
            obj = obj.Translate(0, 0, Inches.Eigth) +
                obj.Clone().Rotate(0, 180, 0).Translate(0, 0, 0)
                + new Cube(Inches.Quarter * .85, Inches.Half, Inches.Quarter * .85, true);

            obj = obj.Rotate(90, 0, 0);

            obj.ToFile("clip-180");
        }
Example #6
0
        public static void makeACBrackets()
        {
            double width = Inches.One * 6.5;
            double height = Inches.One;
            double depth = Inches.One;
            double thickness = Inches.Quarter;

            var mainBox = new Cube(width, depth, height, true);
            var cutout = mainBox.Clone().Scale(1.1, 1, 1).Translate(0, thickness, thickness);
            var hole = new Cylinder(Inches.Eigth, Inches.One * 2, true) { Resolution = 30 }.Rotate(90, 0, 0);


            var whole = mainBox - cutout - hole.Translate(0, 0, Inches.Quarter) - 
                hole.Clone().Translate(-Inches.One * 2, 0, Inches.Quarter) - hole.Clone().Translate(+Inches.One * 2, 0, Inches.Quarter);
            whole.ToFile("acBracket");
        }
Example #7
0
        public void OSCADObject_ClonedObjectsRetainTheirNamesAfterBasicTransforms()
        {
            var obj = new Cube() { Name = "Cube" }
                            .Translate(1, 1, 1);
            obj.Name = "TranslatedCube";
            obj = obj.Rotate(0, 90, 0);
            obj.Name = "RotatedAndTranslatedCube";
            obj = obj.Scale(1, 1, 2);
            obj.Name = "ScaledAndRotatedAndTranslatedCube";

            var clone = obj.Clone();

            Assert.AreEqual("ScaledAndRotatedAndTranslatedCube", clone.Name);

            var children = clone.Children().ToList();
            Assert.AreEqual("RotatedAndTranslatedCube", children[0].Name);
            Assert.AreEqual("TranslatedCube", children[1].Name);
            Assert.AreEqual("Cube", children[2].Name);
        }
Example #8
0
        public void OSCADObject_ClonedObjectsRetainNamesAfterBooleanOperations()
        {
            //Union, Difference using operators
            var obj = new Cube() { Name = "Cube" }
                + new Cylinder() { Name = "Cylinder" } - new Sphere() { Name = "Sphere" };

            obj = obj.Intersection(new Text3D("Heyyy") { Name="Text" });

            var clone = obj.Clone();

            var children = clone.Children().ToList();
            Assert.AreEqual("Text", children[5].Name);
            Assert.AreEqual("Cylinder", children[3].Name);
            Assert.AreEqual("Cube", children[4].Name);
            Assert.AreEqual("Sphere", children[1].Name);
        }