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 Bracket(Model model) { CompositeCurve rrscc1 = CompositeCurve.CreateRoundedRectangle(Plane.YZ, 40, 120, 12, true); CompositeCurve sscc1 = CompositeCurve.CreateSlot(Plane.YZ, 9, 5.25, true); sscc1.Translate(0, 0, 43); CompositeCurve sscc2 = CompositeCurve.CreateSlot(Plane.YZ, 9, 5.25, true); sscc2.Rotate(Utility.DegToRad(90), Vector3D.AxisX, Point3D.Origin); sscc2.Translate(0, 0, -40); Circle c1 = new Circle(Plane.YZ, 4.25); Region r1 = new Region(rrscc1, sscc1, sscc2, c1); Brep ext1 = r1.ExtrudeAsBrep(-4); model.Entities.Add(ext1, "Default", Color.YellowGreen); CompositeCurve cc1 = new CompositeCurve( new Line(Plane.YZ, 8, -10, 11, -10), new Arc(Plane.YZ, new Point2D(11, -5), 5, Utility.DegToRad(270), Utility.DegToRad(360)), new Line(Plane.YZ, 16, -5, 16, +5), new Arc(Plane.YZ, new Point2D(11, +5), 5, Utility.DegToRad(0), Utility.DegToRad(90)), new Line(Plane.YZ, 11, 10, -11, 10), new Arc(Plane.YZ, new Point2D(-11, +5), 5, Utility.DegToRad(90), Utility.DegToRad(180)), new Line(Plane.YZ, -16, +5, -16, -5), new Arc(Plane.YZ, new Point2D(-11, -5), 5, Utility.DegToRad(180), Utility.DegToRad(270)), new Line(Plane.YZ, -11, -10, -8, -10)); Region r2 = cc1.OffsetToRegion(-2.5, 0, false); ext1.ExtrudeAdd(r2, 275); Region ssr2 = Region.CreateSlot(Plane.XY, 12, 5.25); ssr2.Translate(9, 0, 0); ext1.ExtrudeRemovePattern(ssr2, 10, 35, 8, 0, 1); model.Entities.Regen(); }
protected void CreateElements() { // setting scene for saving System.Windows.Media.Brush oldColor = model1.GetBackground().TopColor; model1.Backface.ColorMethod = backfaceColorMethodType.SingleColor; model1.GetBackground().TopColor = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Colors.White); model1.Viewports[0].GetToolBar().Visible = false; model1.GetCoordinateSystemIcon().Visible = false; model1.GetOriginSymbol().Visible = false; model1.GetViewCubeIcon().Visible = false; model1.GetGrid().Visible = false; model1.Flat.EdgeThickness = 10; model1.Flat.SilhouetteThickness = 10; model1.DisplayMode = displayType.Flat; model1.Flat.ColorMethod = flatColorMethodType.EntityMaterial; // sets trimetric view model1.SetView(viewType.Trimetric); // creates the directory to save material elements if (!Directory.Exists(dirName)) { Directory.CreateDirectory(dirName); } else { // deletes all previous files foreach (string filePath in Directory.GetFiles(dirName)) { File.Delete(filePath); } } Entity[] list = new Entity[4]; // initialiazes the plane Plane p = new Plane(); // sets the colors and material of objects Material m = new Material("wood", new Bitmap("../../../../../../dataset/Assets/Textures/Maple.jpg")); model1.Materials.Add(m); Color[] colors = new Color [] { Color.Gray, Color.FromArgb(255, 0xF9, 0x88, 0x66), Color.FromArgb(255, 0xFF, 0x42, 0x0E), Color.FromArgb(255, 0x80, 0xBD, 0x9E), Color.FromArgb(255, 0x89, 0xDA, 0x59) }; // a set of objects #if NURBS // slot devDept.Eyeshot.Entities.Region slot = devDept.Eyeshot.Entities.Region.CreateRoundedRectangle(60, 20, 5, true); devDept.Eyeshot.Entities.Region circle = devDept.Eyeshot.Entities.Region.CreateCircle(3.6); slot = devDept.Eyeshot.Entities.Region.Difference(slot, circle)[0]; circle.Translate(-20, 0, 0); slot = devDept.Eyeshot.Entities.Region.Difference(slot, circle)[0]; circle.Translate(40, 0, 0); slot = devDept.Eyeshot.Entities.Region.Difference(slot, circle)[0]; Brep slotMesh = slot.ExtrudeAsBrep(Vector3D.AxisZ * 5); slotMesh.Rotate(Math.PI / 2, Vector3D.AxisZ); slotMesh.Color = colors[0]; slotMesh.MaterialName = "wood"; slotMesh.ColorMethod = colorMethodType.byEntity; // triangle LinearPath trianglePath = new LinearPath(Point3D.Origin, new Point3D(36, 0, 0), new Point3D(18, 0, 25), Point3D.Origin); devDept.Eyeshot.Entities.Region triangleRegion2 = new devDept.Eyeshot.Entities.Region(trianglePath); Brep triangleMesh = triangleRegion2.ExtrudeAsBrep(Vector3D.AxisY * 5); triangleMesh.Color = colors[1]; triangleMesh.ColorMethod = colorMethodType.byEntity; triangleMesh.Rotate(Utility.DegToRad(90), Vector3D.AxisZ); triangleMesh.Translate(52, -3, 0); // weels Brep weelAxisMesh = Brep.CreateCylinder(3, 65); weelAxisMesh.MaterialName = "wood"; weelAxisMesh.Rotate(Math.PI / 2, Vector3D.AxisY); weelAxisMesh.Color = colors[2]; weelAxisMesh.ColorMethod = colorMethodType.byEntity; devDept.Eyeshot.Entities.Region outer = devDept.Eyeshot.Entities.Region.CreateCircle(Plane.YZ, 12); devDept.Eyeshot.Entities.Region inner = devDept.Eyeshot.Entities.Region.CreateCircle(Plane.YZ, 3); devDept.Eyeshot.Entities.Region weel = devDept.Eyeshot.Entities.Region.Difference(outer, inner)[0]; Brep weelRMesh = weel.ExtrudeAsBrep(10); weelRMesh.Translate(55, 0, 0); weelRMesh.Color = colors[2]; weelRMesh.ColorMethod = colorMethodType.byEntity; Brep weelLMesh = weel.ExtrudeAsBrep(-10); weelLMesh.Translate(10, 0, 0); weelLMesh.Color = colors[2]; weelLMesh.ColorMethod = colorMethodType.byEntity; // cylinder Brep cylMesh = Brep.CreateCylinder(3.5, 40); cylMesh.Color = colors[3]; cylMesh.ColorMethod = colorMethodType.byEntity; //box Brep baseMesh = Brep.CreateBox(40, 40, 5); baseMesh.Color = colors[4]; baseMesh.ColorMethod = colorMethodType.byEntity; #else // slot devDept.Eyeshot.Entities.Region slot = devDept.Eyeshot.Entities.Region.CreateRoundedRectangle(60, 20, 5, true); devDept.Eyeshot.Entities.Region circle = devDept.Eyeshot.Entities.Region.CreateCircle(3.6); slot = devDept.Eyeshot.Entities.Region.Difference(slot, circle)[0]; circle.Translate(-20, 0, 0); slot = devDept.Eyeshot.Entities.Region.Difference(slot, circle)[0]; circle.Translate(40, 0, 0); slot = devDept.Eyeshot.Entities.Region.Difference(slot, circle)[0]; Mesh slotMesh = slot.ExtrudeAsMesh(Vector3D.AxisZ * 5, 0.01, Mesh.natureType.RichSmooth); slotMesh.Rotate(Math.PI / 2, Vector3D.AxisZ); slotMesh.Color = colors[0]; slotMesh.ApplyMaterial("wood", textureMappingType.Cubic, 2, 2); slotMesh.ColorMethod = colorMethodType.byEntity; // triangle LinearPath trianglePath = new LinearPath(Point3D.Origin, new Point3D(36, 0, 0), new Point3D(18, 0, 25), Point3D.Origin); devDept.Eyeshot.Entities.Region triangleRegion2 = new devDept.Eyeshot.Entities.Region(trianglePath); Mesh triangleMesh = triangleRegion2.ExtrudeAsMesh(Vector3D.AxisY * 5, 0.01, Mesh.natureType.RichSmooth); triangleMesh.Color = colors[1]; triangleMesh.ColorMethod = colorMethodType.byEntity; triangleMesh.Rotate(Utility.DegToRad(90), Vector3D.AxisZ); triangleMesh.Translate(52, -3, 0); // weels Mesh weelAxisMesh = Mesh.CreateCylinder(3, 65, 50, Mesh.natureType.RichSmooth); weelAxisMesh.ApplyMaterial("wood", textureMappingType.Cylindrical, 2, 2); weelAxisMesh.Rotate(Math.PI / 2, Vector3D.AxisY); weelAxisMesh.Color = colors[2]; weelAxisMesh.ColorMethod = colorMethodType.byEntity; devDept.Eyeshot.Entities.Region outer = devDept.Eyeshot.Entities.Region.CreateCircle(Plane.YZ, 12); devDept.Eyeshot.Entities.Region inner = devDept.Eyeshot.Entities.Region.CreateCircle(Plane.YZ, 3); devDept.Eyeshot.Entities.Region weel = devDept.Eyeshot.Entities.Region.Difference(outer, inner)[0]; Mesh weelRMesh = weel.ExtrudeAsMesh(10, 0.01, Mesh.natureType.RichSmooth); weelRMesh.Translate(55, 0, 0); weelRMesh.Color = colors[2]; weelRMesh.ColorMethod = colorMethodType.byEntity; Mesh weelLMesh = weel.ExtrudeAsMesh(-10, 0.01, Mesh.natureType.RichSmooth); weelLMesh.Translate(10, 0, 0); weelLMesh.Color = colors[2]; weelLMesh.ColorMethod = colorMethodType.byEntity; // cylinder Mesh cylMesh = Mesh.CreateCylinder(3.5, 40, 50); cylMesh.Color = colors[3]; cylMesh.ColorMethod = colorMethodType.byEntity; //box Mesh baseMesh = Mesh.CreateBox(40, 40, 5); baseMesh.Color = colors[4]; baseMesh.ColorMethod = colorMethodType.byEntity; #endif // blocks containing the geometry Block baseBlock = new Block("Box"); baseBlock.Entities.Add(baseMesh); Block redTriangleBlock = new Block("Slot"); redTriangleBlock.Entities.Add(slotMesh); Block yellowTriangleBlock = new Block("Triangle"); yellowTriangleBlock.Entities.Add(triangleMesh); Block greenBlock = new Block("Cylinder"); greenBlock.Entities.Add(cylMesh); Block weelsBlock = new Block("weels"); weelsBlock.Entities.Add(weelAxisMesh); weelsBlock.Entities.Add(weelRMesh); weelsBlock.Entities.Add(weelLMesh); model1.Blocks.Add(baseBlock); model1.Blocks.Add(redTriangleBlock); model1.Blocks.Add(yellowTriangleBlock); model1.Blocks.Add(greenBlock); model1.Blocks.Add(weelsBlock); // saves entities elements foreach (Block b in model1.Blocks) { // deletes previous entities model1.Entities.Clear(); // adds the entity to the viewport BlockReference reference = new BlockReference(b.Name); model1.Entities.Add(reference); // fits the model in the viewport model1.ZoomFit(); // save image Bitmap materialSphere = model1.RenderToBitmap(1); materialSphere.Save(dirName + "\\" + b.Name + ".bmp"); } // fills ListView with saved images this.listView1.ItemsSource = Fill_listView; // restores scene model1.Backface.ColorMethod = backfaceColorMethodType.EntityColor; model1.GetBackground().TopColor = oldColor; model1.Viewports[0].GetToolBar().Visible = true; model1.GetCoordinateSystemIcon().Visible = true; model1.GetOriginSymbol().Visible = true; model1.GetViewCubeIcon().Visible = true; model1.GetGrid().Visible = true; model1.Flat.EdgeThickness = 1; model1.Flat.SilhouetteThickness = 2; model1.DisplayMode = displayType.Rendered; }