public void CreatePolygonRegion(Model model1) { Region region = Region.CreatePolygon( new Point3D(0, 0, 0), new Point3D(30, 0, 0), new Point3D(15, 40, 0)); region.Color = Color.YellowGreen; region.ColorMethod = colorMethodType.byEntity; model1.Entities.Add(region); model1.Invalidate(); }
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); }
public static void House(Model model) { Region outer = Region.CreatePolygon(new Point3D[] { new Point3D(0, 0), new Point3D(460, 0), new Point3D(460, 100), new Point3D(600, 100), new Point3D(600, 400), new Point3D(0, 400) }); // House's extruded outer profile Solid body = outer.ExtrudeAsSolid(400, 0); // Big room at origin Solid bigRoom = Solid.CreateBox(400, 340, 400); // Moves big room in place bigRoom.Translate(30, 30, 0); // Cuts the big room from the house's body Solid[] firstCut = Solid.Difference(body, bigRoom); // Small room Solid smallRoom = Solid.CreateBox(130, 240, 400); // Moves small room in place smallRoom.Translate(440, 130, 0); // Cuts the small room from the house's body Solid[] secondCut = Solid.Difference(firstCut[0], smallRoom); // Draws the main door profile on a vertical plane Plane pln = new Plane(new Point3D(100, 40, 0), Vector3D.AxisX, Vector3D.AxisZ); Line l1 = new Line(pln, 0, 180, 0, 0); Line l2 = new Line(pln, 0, 0, 120, 0); Line l3 = new Line(pln, 120, 0, 120, 180); Arc a1 = new Arc(pln, new Point2D(60, 155), new Point2D(120, 180), new Point2D(0, 180)); devDept.Eyeshot.Entities.Region reg = new devDept.Eyeshot.Entities.Region(new CompositeCurve(l1, l2, l3, a1)); // Cuts the main door profile from the house's body secondCut[0].ExtrudeRemove(reg, 50, 1); // central horizontal beam Solid beam1 = Solid.CreateBox(680, 30, 40); // moves in place beam1.Translate(-40, 185, 360); // cut the house's body Solid[] thirdCut = Solid.Difference(secondCut[0], beam1); // same for other two horizontal beams Solid beam2 = Solid.CreateBox(680, 20, 40); beam2.Translate(-40, 0, 280); Solid[] fourthCut = Solid.Difference(thirdCut[0], beam2); Solid beam3 = Solid.CreateBox(680, 20, 40); beam3.Translate(-40, 380, 280); Solid[] fifthCut = Solid.Difference(fourthCut[0], beam3); // Intersection tool loop outer = Region.CreatePolygon(Plane.YZ, new Point2D[] { new Point2D(0, 0), new Point2D(400, 0), new Point2D(400, 300), new Point2D(200, 400), new Point2D(0, 300) }); // Tool body Solid intersectionTool = outer.ExtrudeAsSolid(Vector3D.AxisX * 680, 0); // Moves the tool in place intersectionTool.Translate(-40, 0, 0); // Intersects the house's body with the tool Solid[] firstInters = Solid.Intersection(fifthCut[0], intersectionTool); // Intersects the horizontal beams with the tool Solid[] secondInters = Solid.Intersection(beam1, intersectionTool); Solid[] thirdInters = Solid.Intersection(beam2, intersectionTool); Solid[] fourthInters = Solid.Intersection(beam3, intersectionTool); // Adds beams to the scene model.Entities.AddRange(secondInters, Color.SaddleBrown); model.Entities.AddRange(thirdInters, Color.SaddleBrown); model.Entities.AddRange(fourthInters, Color.SaddleBrown); // Basement sweep rail LinearPath rail = new LinearPath(new Point3D[] { new Point3D(220, 0), new Point3D(460, 0), new Point3D(460, 100), new Point3D(600, 100), new Point3D(600, 400), new Point3D(0, 400), new Point3D(0, 0), new Point3D(100, 0) }); // Basement sweep section Region section = Region.CreatePolygon(new Point3D[] { new Point3D(220, 0, 0), new Point3D(220, -7.5, 0), new Point3D(220, 0, 75) }); // Sweep solid Solid basement = section.SweepAsSolid(rail, 0); // Merges sweep with the house's body Solid[] firstUnion = Solid.Union(firstInters[0], basement); // Internal door Solid door = Solid.CreateBox(30, 80, 210); // Moves internal door in place door.Translate(420, 140, 0); // Cuts the internal door from the house's body Solid[] sixthCut = Solid.Difference(firstUnion[0], door); Solid beam10 = Solid.CreateBox(10, 120, 20); beam10.Translate(430, 120, 210); model.Entities.Add(beam10, Color.Gray); Solid[] seventhCut = Solid.Difference(sixthCut[0], beam10); // Window Solid window = Solid.CreateBox(90, 50, 140); // Moves window in place window.Translate(280, -10, 90); // Cuts the window from the house's body Solid[] eighthCut = Solid.Difference(seventhCut[0], window); Solid windowLedge = Solid.CreateBox(100, 35, 5); windowLedge.Translate(275, -5, 85); model.Entities.Add(windowLedge, Color.Gray); Solid[] sixthCut3 = Solid.Difference(eighthCut[0], windowLedge); sixthCut3[0].SmoothingAngle = Utility.DegToRad(1); model.Entities.AddRange(sixthCut3, Color.WhiteSmoke); // Oblique beam loop Region obliqueLoop = Region.CreatePolygon(Plane.YZ, new Point2D[] { new Point2D(200, 0), new Point2D(-60, -130), new Point2D(-60, -150), new Point2D(200, -20) }); // Oblique beam Solid oblique = obliqueLoop.ExtrudeAsSolid(10, 0); // Moves in place oblique.Translate(-40, 0, 420); // A list of entities we need to mirror List <Entity> toBeMirrored = new List <Entity>(); toBeMirrored.Add(oblique); // Copies and adds the oblique beam for (int i = 0; i < 7; i++) { Entity clone = (Entity)oblique.Clone(); clone.Translate((((680 - 8 * 10) / 7.0) + 10) * (i + 1), 0, 0); toBeMirrored.Add(clone); } // Copies and mirrors int count = toBeMirrored.Count; Plane mirrorPlane = Plane.ZX; mirrorPlane.Origin.Y = 200; Mirror m = new Mirror(mirrorPlane); for (int i = 0; i < count; i++) { Entity clone = (Entity)toBeMirrored[i].Clone(); clone.TransformBy(m); toBeMirrored.Add(clone); } // Adds all the array items to the scene model.Entities.AddRange(toBeMirrored, Color.SaddleBrown); }