Ejemplo n.º 1
0
        public void CloneCylinderDescription()
        {
            BSP cyl  = new Cylinder(3);
            BSP cyl2 = cyl.Clone();

            Assert.AreEqual(cyl.Description.Count(), cyl2.Description.Count());
            Assert.IsTrue(cyl.Description.Zip(cyl2.Description, (a, b) => a.Equals(b)).Aggregate((a, b) => a & b));
        }
Ejemplo n.º 2
0
        public static void makeDiceHolder()
        {
            double chamberDiameter = Inches.One;

            var singleChamberCenter = new Cylinder(chamberDiameter, Inches.Half + Inches.Eigth, true)
            {
                Resolution = 6
            };
            var singleChamber = new Cylinder(chamberDiameter + Inches.Eigth, Inches.Half + Inches.Eigth, true)
            {
                Resolution = 6
            } -singleChamberCenter.Scale(1, 1, 2);

            singleChamber = singleChamber.Rotate(0, 0, 30);
            var bottom = singleChamber;

            for (int angle = 60; angle < 420; angle += 60)
            {
                bottom += singleChamber.Clone().Translate(chamberDiameter - Inches.Sixteenth, 0, 0).Rotate(0, 0, angle);
            }

            var hexSection     = bottom.Clone();
            var outerCylCenter = new Cylinder(chamberDiameter * 2.9, Inches.Half, true)
            {
                Resolution = 90
            }.Translate(0, 0, Inches.Eigth);
            var outerCyl = (new Cylinder(chamberDiameter * 2.9 + Inches.Eigth, Inches.Half, true)
            {
                Resolution = 90
            } -outerCylCenter).Translate(0, 0, bottom.Bounds().ZMin + Inches.Half);

            bottom += outerCyl;

            var lidCenter = new Cylinder(chamberDiameter * 2.9 + Inches.Eigth + Inches.Sixteenth * .5, Inches.One, true)
            {
                Resolution = 90
            }.Translate(0, 0, Inches.Eigth);
            var lid = (new Cylinder(chamberDiameter * 2.9 + Inches.Quarter + Inches.Sixteenth * .5, Inches.One, true)
            {
                Resolution = 90
            } -lidCenter).Translate(0, 0, bottom.Bounds().ZMin + Inches.Half);

            var top = lid.Clone().Mirror(0, 0, 1).Rotate(0, 180, 0);
            //OSCADObject dragon = ImportedImage.FromFile("dragonInsignia.png", new ImageImportOptions() {
            //    UseGrayScale = true,
            //    HeightMapping = ImageImportOptions.HeightMappingMode.None,
            //    SimplificationAmount = 100
            //});
            //var topBounds = top.Bounds();

            //dragon = dragon.Scale(.1, .1, Inches.Quarter).Translate(-topBounds.Length/2 + Inches.Sixteenth,  -topBounds.Width/2 + Inches.Sixteenth, topBounds.ZMin - Inches.Eigth);

            var whole = top;//bottom;// /*bottom + */ top - dragon;

            whole.ToFile("diceHolder_cap").Open();
        }
Ejemplo n.º 3
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");
        }
        public static void Main(string[] args)
        {
            var engine = new GasolineEngine
            {
                Model           = "aQR25DE",
                Description     = "Nissan X-Trail",
                Power           = 175,
                NumOfSparkPlugs = 4,
                //Cost = 2300
                Cost = 1000
            };

            var cylinder = new Cylinder
            {
                Diameter       = 89,
                WearOutPercent = 0
            };

            engine.Cylinders.Add(cylinder.Clone());
            engine.Cylinders.Add(cylinder.Clone());
            engine.Cylinders.Add(cylinder.Clone());
            engine.Cylinders.Add(cylinder.Clone());

            engine.Cylinders.Last().WearOutPercent = 80;


            IValidator validator = new ObjectValidator();

            IEnumerable <ValidationResult> report = validator.Validate(engine);



            var errors = report.ToArray();

            Console.ReadLine();
        }
Ejemplo n.º 5
0
        private static OSCADObject makeStandCap()
        {
            OSCADObject center = new Cube(Inches.One - Inches.Sixteenth, Inches.Half - Inches.Sixteenth, Inches.Quarter, true);

            OSCADObject outerColumn = new Cylinder(Inches.One, Inches.One, true).Resize(Inches.One * 1.5, Inches.Half * 1.5, Inches.One);
            var         bnds        = center.Bounds();

            OSCADObject top = new Cylinder(Inches.One, Inches.One, true)
                              .Resize(Inches.One * 2.25, Inches.Half * 2.25, Inches.Quarter);
            OSCADObject cutout = new Cylinder(Inches.One, Inches.One, true)
                                 .Resize(Inches.One * 2.1, Inches.Half * 2.1, Inches.Quarter);

            top = top - cutout.Translate(0, 0, Inches.Quarter / 2);


            OSCADObject brim = top.Clone();

            var obj = center + top.Translate(0, 0, bnds.Height / 2 + Inches.Sixteenth / 2);

            return(obj);
        }