Ejemplo n.º 1
0
        public static void Flange(Model model)
        {
            CompositeCurve cc1 = new CompositeCurve(
                new Line(Plane.XZ, 15, 40, 29, 40),
                new Arc(Plane.XZ, new Point2D(29, 39), 1, 0, Utility.DegToRad(90)),
                new Line(Plane.XZ, 30, 39, 30, 16),
                new Arc(Plane.XZ, new Point2D(36, 16), 6, Math.PI, Utility.DegToRad(270)),
                new Line(Plane.XZ, 36, 10, 79, 10),
                new Arc(Plane.XZ, new Point2D(79, 9), 1, 0, Utility.DegToRad(90)),
                new Line(Plane.XZ, 80, 9, 80, 6),
                new Arc(Plane.XZ, new Point2D(86, 6), 6, Utility.DegToRad(180), Utility.DegToRad(270)),
                new Line(Plane.XZ, 86, 0, 130, 0));

            Region reg = cc1.OffsetToRegion(5, 0, false);

            Brep rev1 = reg.RevolveAsBrep(Math.PI * 2, Vector3D.AxisZ, Point3D.Origin);

            model.Entities.Add(rev1, System.Drawing.Color.Aqua);

            Region cssr1 = Region.CreateCircularSlot(0, Utility.DegToRad(30), 60, 8);

            rev1.ExtrudeRemovePattern(cssr1, new Interval(0, 50), Point3D.Origin, Utility.DegToRad(360) / 3, 3);

            Region rr1 = Region.CreateRectangle(90, -40, 50, 80);

            rev1.ExtrudeRemovePattern(rr1, new Interval(0, 50), Point3D.Origin, Utility.DegToRad(360) / 2, 2);

            Region cr1 = Region.CreateCircle(110, 0, 10);

            const int numHoles = 8;

            rev1.ExtrudeRemovePattern(cr1, 50, Point3D.Origin, Utility.DegToRad(360) / numHoles, numHoles);

            model.Entities.Regen();
        }
Ejemplo n.º 2
0
        public void CreateCircleRegion(Model model1)
        {
            Region region = Region.CreateCircle(30);

            region.Color       = Color.Blue;
            region.ColorMethod = colorMethodType.byEntity;
            model1.Entities.Add(region);
            model1.Invalidate();
        }
Ejemplo n.º 3
0
        public static void Locomotive(Model model)
        {
            Region r1 = Region.CreateRectangle(110, 38);

#if NURBS
            Region r2 = Region.CreateRectangle(0, 19, 8, 19);
#else
            Ellipse el = new Ellipse(0, 19, 0, 8, 19);
            el.Regen(1);
            Region r2 = new Region(new LinearPath(el.Vertices), Plane.XY, false);
#endif
            Region u1 = Region.Union(r1, r2)[0];

            Region r3 = Region.CreateCircle(17, -6, 9);

            Region u2 = Region.Union(u1, r3)[0];

            r3.Translate(20, 0, 0);

            Region u3 = Region.Union(u2, r3)[0];

            Region r4 = Region.CreateCircle(70, 0, 15);

            Region u4 = Region.Union(u3, r4)[0];

            Region r5 = Region.CreateCircle(50, 38, 10);

            Region u5 = Region.Union(u4, r5)[0];

            Region r6 = Region.CreateRectangle(79, 36, 44, 14);

            Region u6 = Region.Union(u5, r6)[0];

            Region r7 = Region.CreateRectangle(-11, 14, 10, 10);

            Region u7 = Region.Union(u6, r7)[0];

            Region r8 = Region.CreatePolygon(new Point2D(-15, -8), new Point2D(4, -8), new Point2D(4, 8));

            Region u8 = Region.Union(u7, r8)[0];

            Region r9 = Region.CreatePolygon(new Point2D(20, 20), new Point2D(32, 62), new Point2D(26, 72), new Point2D(14, 72), new Point2D(8, 62));

            Region u9 = Region.Union(u8, r9)[0];

            model.Entities.Add(u9, Color.IndianRed);
        }
Ejemplo n.º 4
0
        public static void Medal(Model model)
        {
            // materials
            Material alu = Material.Aluminium;

            alu.Diffuse     = Color.White;
            alu.Environment = 0.4f;

            string medalMatName = "Alu";

            alu.Name = medalMatName;

            model.Materials.Add(alu);


            string woodMatName = "Wood";

            Material wood = new Material(woodMatName, new Bitmap(MainWindow.GetAssetsPath() + "Textures/Wenge.jpg"));

            model.Materials.Add(wood);



            // medal
            Solid sphere = Solid.CreateSphere(200, 120, 60);

            sphere.Rotate(Math.PI / 2, Vector3D.AxisY);

            sphere.Translate(0, 0, -190);

            Solid cylinder = Region.CreateCircle(Plane.XY, 0, 0, 50).ExtrudeAsSolid(100, 0.1);

            Solid[] intersection = Solid.Intersection(sphere, cylinder);

            Solid lens = intersection[0];

            Text eyeshotText = new Text(-45.5, -8, 0, "eyeshot", 19);

            eyeshotText.Translate(0, 0, 2);

            List <Solid> solidItems = new List <Solid>();

            solidItems.Add(lens);

            solidItems.AddRange(model.ExtrudeText(eyeshotText, 0.01, new Vector3D(0, 0, 10), true));

            Solid medal = Solid.Union(solidItems.ToArray())[0];

            medal.ColorMethod  = colorMethodType.byEntity;
            medal.MaterialName = "alu";
            medal.Translate(0, 0, 2);

            model.Entities.Add(medal, Color.White);


            // jewel case
            Solid b1 = Solid.CreateBox(140, 140, 12);

            b1.Translate(-70, -70, 0);

            Solid b2 = Solid.CreateBox(108, 108, 12);

            b2.Translate(-54, -54, 2);

            Solid[] diff1 = Solid.Difference(b1, b2);

            Plane pln = Plane.YZ;

            Line ln1 = new Line(pln, 0, 0, 4, 0);
            Line ln2 = new Line(pln, 4, 0, 4, 4);
            Line ln3 = new Line(pln, 4, 4, 8, 4);
            Arc  a1  = new Arc(pln, new Point2D(12, 4), 4, Math.PI / 2, Math.PI);
            Line ln4 = new Line(pln, 12, 8, 12, 12);
            Line ln5 = new Line(pln, 12, 12, 0, 12);
            Line ln6 = new Line(pln, 0, 12, 0, 0);

            CompositeCurve sect = new CompositeCurve(ln1, ln2, ln3, a1, ln4, ln5, ln6);

            sect.Translate(0, -70, 0);

            devDept.Eyeshot.Entities.Region sectReg = new devDept.Eyeshot.Entities.Region(sect);

            LinearPath rail = new LinearPath(new Point3D[] { new Point3D(0, -70, 0), new Point3D(70, -70, 0), new Point3D(70, +70, 0), new Point3D(-70, +70, 0), new Point3D(-70, -70, 0), new Point3D(0, -70, 0) });

            Solid frame = sectReg.SweepAsSolid(rail, 0.1);

            Solid[] diff2 = Solid.Difference(diff1[0], frame);

            Solid jewelCase = diff2[0];

            jewelCase.ApplyMaterial(woodMatName, textureMappingType.Cubic, 1, 1);

            model.Entities.Add(jewelCase, Color.FromArgb(32, 0, 0));
        }