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 static void CompositeCurveMeshing(Model model)
        {
            MainWindow.SetDisplayMode(model, displayType.Shaded);

            CompositeCurve outer = new CompositeCurve();

            outer.CurveList.Add(new Line(0, 0, 10, 0));
            outer.CurveList.Add(new Line(10, 0, 10, 6));
            outer.CurveList.Add(new Line(10, 6, 0, 6));
            outer.CurveList.Add(new Line(0, 6, 0, 0));

            CompositeCurve inner1 = new CompositeCurve();

            inner1.CurveList.Add(new Line(2, 2, 6, 2));
            inner1.CurveList.Add(new Line(6, 2, 2, 3));
            inner1.CurveList.Add(new Line(2, 3, 2, 2));

            CompositeCurve inner2 = new CompositeCurve();

            inner2.CurveList.Add(new Circle(8, 4, 0, 1));

            CompositeCurve inner3 = new CompositeCurve();

            inner3.CurveList.Add(new Circle(6, 4, 0, .75));

            Region reg = new Region(outer, inner1, inner2, inner3);

            Mesh m = UtilityEx.Triangulate(reg, .15);

            model.Entities.Add(m, Color.Salmon);
        }
Ejemplo n.º 3
0
        private void CreateChair()
        {
            CreateBoxNTranslate(10, 10, 50, -30, 40, 0);  //front right leg chair
            CreateBoxNTranslate(10, 10, 50, 20, 40, 0);   //front left leg chair

            CreateBoxNTranslate(10, 10, 120, -30, 90, 0); //back right leg chair
            CreateBoxNTranslate(10, 10, 120, 20, 90, 0);  //back left leg chair

            CreateBoxNTranslate(70, 5, 20, -35, 90, 120); // chair top



            string ChairTopSlabName = "ChairTopSlab";
            Block  b = new Block();

            double width = 70;
            double depth = 5;
            double dimA  = 1000;
            double dimB  = 800;

            Point2D[] outerPoints = new Point2D[7];

            outerPoints[0] = new Point2D(0, dimB);
            outerPoints[1] = new Point2D(dimA, dimB);
            outerPoints[2] = new Point2D(dimA, 0);
            outerPoints[3] = new Point2D(width, 0);
            outerPoints[4] = new Point2D(width, depth);
            outerPoints[5] = new Point2D(0, depth);
            outerPoints[6] = (Point2D)
                             outerPoints[0].Clone();

            LinearPath outer = new LinearPath(Plane.XY, outerPoints);

            Point2D[] innerPoints = new Point2D[5];

            innerPoints[0] = new Point2D(-30, 0);
            innerPoints[1] = new Point2D(-30, 60);
            innerPoints[2] = new Point2D(30, 60);
            innerPoints[3] = new Point2D(30, 0);
            innerPoints[4] = (Point2D)innerPoints[0].Clone();

            LinearPath inner = new LinearPath(Plane.XY, innerPoints);

            devDept.Eyeshot.Entities.Region reg = new devDept.Eyeshot.Entities.Region(outer, inner);

            Mesh m2 = reg.ExtrudeAsMesh(10, 0.1, Mesh.natureType.Plain);

            m2.ColorMethod  = colorMethodType.byEntity;
            m2.Color        = Color.White;
            m2.MaterialName = ChairTopSlabName;

            b.Entities.Add(m2);

            viewportLayout1.Blocks.Add("ChairTopSlab", b);


            BlockReference reference = new BlockReference(0, 40, 60, "ChairTopSlab", 1, 1, 1, 0);

            viewportLayout1.Entities.Add(reference, 0);
        }
Ejemplo n.º 4
0
        public Entity CreateHitRegion(double xTarget, double yTarget)
        {
            this.xTarget = xTarget;
            this.yTarget = yTarget;

            devDept.Eyeshot.Entities.Region hitRegion = new devDept.Eyeshot.Entities.Region(lpTarget, Plane.XY);
            return(hitRegion);
        }
Ejemplo n.º 5
0
        private void CreateArrowsDirections()
        {
            // removes previous arrows if present
            if (tempArrows != null)
            {
                model1.TempEntities.Remove(tempArrows[0]);
                model1.TempEntities.Remove(tempArrows[1]);
                model1.TempEntities.Remove(tempArrows[2]);
                model1.TempEntities.Remove(tempArrows[3]);
            }

            //creates 4 temporary arrows on the current moving plane to display when the mouse is over an entity
            tempArrows = new Mesh[4];

            devDept.Eyeshot.Entities.Region arrowShape = new devDept.Eyeshot.Entities.Region(new LinearPath(xyzPlane, new Point2D[]
            {
                new Point2D(0, -2),
                new Point2D(4, -2),
                new Point2D(4, -4),
                new Point2D(10, 0),
                new Point2D(4, 4),
                new Point2D(4, 2),
                new Point2D(0, 2),
                new Point2D(0, -2),
            }), xyzPlane);

            //right arrow
            tempArrows[0] = arrowShape.ExtrudeAsMesh(2, 0.1, Mesh.natureType.Plain);
            tempArrows[0].Regen(0.1);
            tempArrows[0].Color = Color.FromArgb(100, Color.Red);

            //top arrow
            tempArrows[1] = (Mesh)tempArrows[0].Clone();
            tempArrows[1].Rotate(Math.PI / 2, xyzPlane.AxisZ);
            tempArrows[1].Regen(0.1);

            //left arrow
            tempArrows[2] = (Mesh)tempArrows[0].Clone();
            tempArrows[2].Rotate(Math.PI, xyzPlane.AxisZ);
            tempArrows[2].Regen(0.1);

            //bottom arrow
            tempArrows[3] = (Mesh)tempArrows[0].Clone();
            tempArrows[3].Rotate(-Math.PI / 2, xyzPlane.AxisZ);
            tempArrows[3].Regen(0.1);

            Vector3D diagonalV  = new Vector3D(tempArrows[0].BoxMin, tempArrows[0].BoxMax);
            double   offset     = Math.Max(Vector3D.Dot(diagonalV, xyzPlane.AxisX), Vector3D.Dot(diagonalV, xyzPlane.AxisY));
            Vector3D translateX = xyzPlane.AxisX * offset / 2;
            Vector3D translateY = xyzPlane.AxisY * offset / 2;

            tempArrows[0].Translate(translateX);
            tempArrows[1].Translate(translateY);
            tempArrows[2].Translate(-1 * translateX);
            tempArrows[3].Translate(-1 * translateY);

            centerOfArrows = Point3D.Origin;
        }
Ejemplo n.º 6
0
        void MakeFemMeshSample()
        {
            Line l1 = new Line(0, 0, 100, 0);
            Line l2 = new Line(100, 0, 100, 30);
            Line l3 = new Line(100, 30, 80, 30);
            Arc  a1 = new Arc(80, 50, 0, 20, Utility.DegToRad(180), Utility.DegToRad(270));
            Line l4 = new Line(60, 50, 60, 80);
            Line l5 = new Line(60, 80, 30, 80);
            Line l6 = new Line(30, 80, 30, 31);
            Arc  a2 = new Arc(29, 31, 0, 1, Utility.DegToRad(270), Utility.DegToRad(360));
            Line l7 = new Line(29, 30, 26, 30);
            Arc  a3 = new Arc(26, 31, 0, 1, Utility.DegToRad(180), Utility.DegToRad(270));
            Line l8 = new Line(25, 31, 25, 80);

            Line l9  = new Line(25, 80, 15, 80);
            Line l10 = new Line(15, 80, 15, 31);
            Arc  a4  = new Arc(14, 31, 0, 1, Utility.DegToRad(270), Utility.DegToRad(360));
            Line l11 = new Line(14, 30, 11, 30);
            Arc  a5  = new Arc(11, 31, 0, 1, Utility.DegToRad(180), Utility.DegToRad(270));
            Line l12 = new Line(10, 31, 10, 80);
            Line l13 = new Line(10, 80, 0, 80);
            Line l14 = new Line(0, 80, 0, 0);

            Circle c1 = new Circle(20, 15, 0, 5);
            Circle c2 = new Circle(35, 15, 0, 5);
            Circle c3 = new Circle(50, 15, 0, 5);
            Circle c4 = new Circle(65, 15, 0, 5);

            devDept.Eyeshot.Entities.Region reg = new devDept.Eyeshot.Entities.Region(new ICurve[] { new CompositeCurve(l1, l2, l3, l4, l5, l6, l7, l8, l9, l10, l11, l12, l13, l14, a1, a2, a3, a4, a5), c1,
                                                                                                     c2, c3, c4 }, Plane.XY);

            Mesh m = UtilityEx.Triangulate(reg, 3);

            Material copper = Material.Copper;

            copper.ElementThickness = 6;
            copper.ElementType      = elementType.PlaneStress;

            FemMesh fMesh = m.ConvertToFemMesh(copper, true);

            fMesh.FixAll(new Point3D(0, 0), new Point3D(100, 0), .1);

            fMesh.SetForce(new Point3D(0, 70), new Point3D(50, 70), .1, new Vector3D(-1, 0, 0));

            model1.Entities.Add(fMesh);

            model1.Invalidate();

            Solver s1 = new Solver(fMesh);

            model1.DoWork(s1);
            model1.Invalidate();

            fMesh.PlotMode      = FemMesh.plotType.U;
            fMesh.NodalAverages = true;
            fMesh.ComputePlot(model1, model1.ActiveViewport.Legends[0]);
            model1.ZoomFit();
        }
Ejemplo n.º 7
0
        public void CreateHexagonRegion(Model model1)
        {
            Region region = Region.CreateHexagon(30);

            region.Color       = Color.Purple;
            region.ColorMethod = colorMethodType.byEntity;
            model1.Entities.Add(region);
            model1.Invalidate();
        }
Ejemplo n.º 8
0
        public void CreateEllipseRegion(Model model1)
        {
            Region region = Region.CreateEllipse(60, 30);

            region.Color       = Color.LightPink;
            region.ColorMethod = colorMethodType.byEntity;
            model1.Entities.Add(region);
            model1.Invalidate();
        }
Ejemplo n.º 9
0
        public void CreateRoundedRectangleRegion(Model model1)
        {
            Region region = Region.CreateRoundedRectangle(50, 30, 10);

            region.Color       = Color.DarkGreen;
            region.ColorMethod = colorMethodType.byEntity;
            model1.Entities.Add(region);
            model1.Invalidate();
        }
Ejemplo n.º 10
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.º 11
0
        public void CreateSlotRegion(Model model1)
        {
            double length = 50;
            double radius = 3;
            Region region = Region.CreateSlot(length, radius);

            region.Color       = Color.DarkRed;
            region.ColorMethod = colorMethodType.byEntity;
            model1.Entities.Add(region);
            model1.Invalidate();
        }
Ejemplo n.º 12
0
        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();
        }
Ejemplo n.º 13
0
        public void CreateCircularSlotRegion(Model model1)
        {
            double angle      = Utility.DegToRad(90);
            double radius     = 30;
            double slotRadius = 10;

            Region region = Region.CreateCircularSlot(angle, radius, slotRadius);

            region.Color       = Color.Goldenrod;
            region.ColorMethod = colorMethodType.byEntity;
            model1.Entities.Add(region);
            model1.Invalidate();
        }
Ejemplo n.º 14
0
        public void CreateExtrudeMesh(Model model1)
        {
            Shapes shapes = new Shapes();
            // Curve로 Region 생성
            Region region = new Region(shapes.RoundRectangle());

            Mesh mesh = region.ExtrudeAsMesh(new Vector3D(0, 0, 50), 0.001, Mesh.natureType.Plain);

            mesh.Color       = Color.Aquamarine;
            mesh.ColorMethod = colorMethodType.byEntity;
            model1.Entities.Add(mesh);
            model1.Invalidate();
        }
Ejemplo n.º 15
0
        public void CreateRegionFromCurve(Model model1)
        {
            Shapes         shapes    = new Shapes();
            CompositeCurve roundRect = shapes.RoundRectangle();

            // curve로 Region 만듦
            Region region = new Region(roundRect);

            region.Color       = Color.Blue;
            region.ColorMethod = colorMethodType.byEntity;
            model1.Entities.Add(region);
            model1.Invalidate();
        }
Ejemplo n.º 16
0
        public static void Pocket(Model model)
        {
            Point2D[] pts = new Point2D[]
            {
                new Point2D(0, 0),
                new Point2D(40, 0),
                new Point2D(40, 20),
                new Point2D(60, 20),
                new Point2D(60, 10),
                new Point2D(100, 10),
                new Point2D(100, 60),
                new Point2D(60, 60),
                new Point2D(60, 30),
                new Point2D(40, 30),
                new Point2D(40, 80),
                new Point2D(0, 80),
                new Point2D(0, 0),
            };

            LinearPath outerContour = new LinearPath(Plane.XY, pts);

            outerContour.LineWeightMethod = colorMethodType.byEntity;
            outerContour.LineWeight       = 3;

            model.Entities.Add(outerContour, Color.OrangeRed);

            Circle innerContour = new Circle(20, 60, 0, 6);

            innerContour.LineWeightMethod = colorMethodType.byEntity;
            innerContour.LineWeight       = 3;

            model.Entities.Add(innerContour, Color.OrangeRed);

            Region r1 = new Region(new ICurve[] { outerContour, innerContour }, Plane.XY, true);

            ICurve[] passes = r1.Pocket(4, cornerType.Round, .1);

            const double zStep     = 2;
            const int    stepCount = 10;

            for (int i = 1; i < stepCount; i++)
            {
                foreach (Entity crv in passes)
                {
                    Entity en = (Entity)crv.Clone();
                    en.Translate(0, 0, -i * zStep);
                    model.Entities.Add(en, Color.DarkBlue);
                }
            }
        }
Ejemplo n.º 17
0
        public void CreateSweepMesh(Model model1)
        {
            // Shapes를 통해서 RoundRectangle과 Arc 생성
            Shapes shapes = new Shapes();
            Region region = new Region(shapes.RoundRectangle());
            Arc    arc    = shapes.StandingArc();

            // RoundRectangle을 Arc를 따라 쓸기
            Mesh mesh = region.SweepAsMesh(arc, 0.001);

            mesh.Color       = Color.Red;
            mesh.ColorMethod = colorMethodType.byEntity;
            model1.Entities.Add(mesh);
            model1.Invalidate();
        }
Ejemplo n.º 18
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.º 19
0
        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();
        }
Ejemplo n.º 20
0
        private Mesh BuildMeshWithTexture()
        {
            Material mat = new Material("Marble", new Bitmap("../../../../../../dataset/Assets/Textures/Maple.jpg"));

            model1.Materials.Add(mat);

            const double tol    = 0.01;    // chordal error
            const double radius = 0.4;     // holes radius

            // Plate with holes
            ICurve profile = new CompositeCurve(new Line(0, 0, 8, 0),
                                                new Arc(new Point3D(8, 2, 0), 2, 6 * Math.PI / 4, 2 * Math.PI),
                                                new Line(10, 2, 10, 6),
                                                new Line(10, 6, 0, 6),
                                                new Line(0, 6, 0, 0));

            ICurve[] holes = new ICurve[20];

            int count = 0;

            for (int y = 0; y < 4; y++)
            {
                for (int x = 0; x < 5; x++)
                {
                    holes[count] = new Circle(new Point3D(1 + x * 1, 1 + y * 1, 0), radius);
                    holes[count].Reverse(); // holes have wrong orientation, we must reverse them
                    count++;
                }
            }

            List <ICurve> contours = new List <ICurve>()
            {
                profile
            };

            contours.AddRange(holes);
            devDept.Eyeshot.Entities.Region region = new devDept.Eyeshot.Entities.Region(contours, Plane.XY, false);
            Mesh plate = region.ExtrudeAsMesh(new Vector3D(0, 0, 0.25), tol, Mesh.natureType.RichSmooth);

            plate.FlipNormal();
            plate.NormalAveragingMode = Mesh.normalAveragingType.AveragedByAngle;
            plate.ApplyMaterial(mat.Name, textureMappingType.Cubic, 1, 1);
            plate.Translate(10, 0, 0);
            return(plate);
        }
Ejemplo n.º 21
0
        public void CreateRevolveMesh(Model model1)
        {
            Shapes shapes = new Shapes();
            Region region = new Region(shapes.StandingCircle());

            var startAngle = Utility.DegToRad(0);
            var deltaAngle = Utility.DegToRad(90);
            var axisStart  = new Point3D(-50, 0, 0);
            var axisEnd    = new Point3D(-50, 0, 100);
            var slices     = 10;
            var tolerance  = 0.1;

            Mesh mesh = region.RevolveAsMesh(startAngle, deltaAngle, axisStart, axisEnd, slices, tolerance, Mesh.natureType.Plain);

            mesh.Color       = Color.YellowGreen;
            mesh.ColorMethod = colorMethodType.byEntity;
            model1.Entities.Add(mesh);
            model1.Invalidate();
        }
Ejemplo n.º 22
0
        public static void CreateHybridEntity(Model vp)
        {
            double width = 0.5;

            Point3D[] profilePoints = new Point3D[]
            {
                new Point3D(-5, 0, 0), new Point3D(5, 0, 0), new Point3D(5, 0.5, 0),
                new Point3D(width, width, 0), new Point3D(width, 10 - width, 0), new Point3D(5, 10 - width, 0),
                new Point3D(5, 10, 0), new Point3D(-5, 10, 0), new Point3D(-5, 10 - width, 0),
                new Point3D(-width, 10 - width, 0), new Point3D(-width, width, 0), new Point3D(-5, width, 0), new Point3D(-5, 0, 0)
            };
            LinearPath profileLp = new LinearPath(profilePoints);
            Region     profile   = new Region(profileLp);

            double length1 = 80;

            MyHybridMesh m = profile.ExtrudeAsMesh <MyHybridMesh>(new Vector3D(0, 0, length1), 0.1, Mesh.natureType.Plain);

            m.Rotate(Math.PI / 2, Vector3D.AxisZ);
            m.Translate(5, 0, 0);
            m.wireVertices = BuildWire(length1).ToArray();
            vp.Entities.Add(m, Color.Red);

            MyHybridMesh m2 = (MyHybridMesh)m.Clone();

            m2.Rotate(Math.PI, Vector3D.AxisZ);
            m2.Translate(60, 0, 0);
            vp.Entities.Add(m2, Color.Red);

            double       length2 = 60;
            MyHybridMesh m3      = profile.ExtrudeAsMesh <MyHybridMesh>(new Vector3D(0, 0, length2), 0.1, Mesh.natureType.Plain);

            m3.Rotate(Math.PI / 2, Vector3D.AxisZ);
            m3.Translate(5, 0, 0);
            m3.wireVertices = BuildWire(length2).ToArray();
            m3.Rotate(Math.PI / 2, Vector3D.AxisY);
            m3.Translate(0, 0, length1);
            vp.Entities.Add(m3, Color.Green);
        }
Ejemplo n.º 23
0
        private devDept.Eyeshot.Entities.Region BuildRegion()
        {
            // Face
            Circle outer = new Circle(Point3D.Origin, 6);

            // Eyes
            Ellipse inner1 = new Ellipse(new Point3D(-2, 2, 0), 0.5, 1);
            Ellipse inner2 = new Ellipse(new Point3D(2, 2, 0), 0.5, 1);

            // Mouth
            Circle  circle = new Circle(Point3D.Origin, 4);
            Point3D i1;
            Point3D i2;

            CompositeCurve.IntersectionLineCircle3D(new Line(-10, 0, 10, 0), circle, out i1, out i2);
            Arc arc1 = new Arc(new Point3D(0, 2, 0), i1, i2);

            ICurve[] segments;
            circle.SplitBy(new List <Point3D> {
                i1, i2
            }, out segments);
            CompositeCurve inner3 = new CompositeCurve(new List <ICurve>()
            {
                arc1, segments[1]
            });

            // Smile region
            devDept.Eyeshot.Entities.Region reg = new devDept.Eyeshot.Entities.Region(new List <ICurve> {
                outer, inner1, inner2, inner3
            });
            reg.ColorMethod = colorMethodType.byEntity;
            reg.Color       = System.Drawing.Color.FromArgb(255, 180, 30);
            reg.TransformBy(new Translation(12, 25, 0) * new Rotation(Math.PI / 2, Vector3D.AxisX));

            return(reg);
        }
Ejemplo n.º 24
0
        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);
        }
Ejemplo n.º 25
0
        private void RebuildChair()
        {
            string currentMatName = (currentFrameMaterial == materialEnum.Cherry) ? cherryMatName : mapleMatName;

            model1.Entities.Clear();
            model1.Labels.Clear();

            double legDepth  = 3;
            double legWidth  = 3;
            double legHeight = 56.5;

            double seatDepth  = 29;
            double seatWidth  = sizeTrackBar.Value;
            double seatHeight = 1.6;
            double seatY      = 27.4;

            //
            // Build the legs
            //
            Mesh leg1 = MakeBox(legWidth, legDepth, legHeight);
            Mesh leg4 = (Mesh)leg1.Clone();


            Mesh leg2 = MakeBox(legWidth, legDepth, seatY);
            Mesh leg3 = (Mesh)leg2.Clone();

            leg2.Translate(seatDepth - legDepth, 0, 0);
            leg3.Translate(seatDepth - legDepth, seatWidth - legWidth, 0);
            leg4.Translate(0, seatWidth - legWidth, 0);

            AddEntityWithMaterial(ref leg1, currentMatName);
            AddEntityWithMaterial(ref leg2, currentMatName);
            AddEntityWithMaterial(ref leg3, currentMatName);
            AddEntityWithMaterial(ref leg4, currentMatName);

            //
            // Build the seat
            //
            double dx             = 0.3;
            double dy             = 0.2;
            double delta          = 0.1;
            double seatPartDepth  = 4.5;
            double seatPartOffset = 0.5;

            Point3D[] seatFirstPartPoints = { new Point3D(legDepth + delta,                         0, 0),
                                              new Point3D(seatPartDepth,                            0, 0),
                                              new Point3D(seatPartDepth,    seatWidth,                 0),
                                              new Point3D(legDepth + delta, seatWidth,                 0),
                                              new Point3D(legDepth + delta, seatWidth - legWidth + dy, 0),
                                              new Point3D(-dx,              seatWidth - legWidth,      0),
                                              new Point3D(-dx,              legWidth,                  0),
                                              new Point3D(legDepth + delta, legWidth + dy,             0),
                                              new Point3D(legDepth + delta,                         0, 0) };

            Region seatFirstPart = new Region(new LinearPath(seatFirstPartPoints));
            Mesh   seatPart0     = seatFirstPart.ExtrudeAsMesh(new Vector3D(0, 0, seatHeight), 0.01, Mesh.natureType.Smooth);

            seatPart0.Translate(0, -dy, seatY);
            Mesh seatPart1 = MakeBox(seatWidth + 2 * dx, seatPartDepth, seatHeight);

            seatPart1.Translate(seatPartDepth + seatPartOffset, -dy, seatY);

            Mesh seatPart2 = (Mesh)seatPart1.Clone();

            seatPart2.Translate(seatPartDepth + seatPartOffset, 0, 0);

            Mesh seatPart3 = (Mesh)seatPart2.Clone();

            seatPart3.Translate(seatPartDepth + seatPartOffset, 0, 0);

            Mesh seatPart4 = (Mesh)seatPart3.Clone();

            seatPart4.Translate(seatPartDepth + seatPartOffset, 0, 0);

            Mesh seatPart5 = (Mesh)seatPart4.Clone();

            seatPart5.Translate(seatPartDepth + seatPartOffset, 0, 0);

            model1.Entities.Add(seatPart0, plasticMatName);
            model1.Entities.Add(seatPart1, plasticMatName);
            model1.Entities.Add(seatPart2, plasticMatName);
            model1.Entities.Add(seatPart3, plasticMatName);
            model1.Entities.Add(seatPart4, plasticMatName);
            model1.Entities.Add(seatPart5, plasticMatName);

            //
            // Build the bars under the seat
            //
            double underSeatXBarWidth  = legWidth * 0.8;
            double underSeatXBarDepth  = seatDepth - 2 * legDepth;
            double underSeatXBarHeight = 5.0;

            double underSeatYBarWidth  = seatWidth - 2 * legWidth;
            double underSeatYBarDepth  = legDepth * 0.8;
            double underSeatYBarHeight = underSeatXBarHeight;

            Mesh barUnderSeatLeft = MakeBox(underSeatXBarWidth, underSeatXBarDepth, underSeatXBarHeight);

            barUnderSeatLeft.Translate(legDepth, (legWidth - underSeatXBarWidth) / 2, seatY - underSeatXBarHeight);

            Mesh barUnderSeatRight = (Mesh)barUnderSeatLeft.Clone();

            barUnderSeatRight.Translate(0, seatWidth - legWidth, 0);

            Mesh barUnderSeatBack = MakeBox(seatWidth - 2 * legWidth, legDepth * 0.8, underSeatYBarHeight);

            barUnderSeatBack.Translate((legDepth - underSeatYBarDepth) / 2, legWidth, seatY - underSeatYBarHeight);

            Mesh barUnderSeatFront = (Mesh)barUnderSeatBack.Clone();

            barUnderSeatFront.Translate(seatDepth - legDepth, 0, 0);

            AddEntityWithMaterial(ref barUnderSeatLeft, currentMatName);
            AddEntityWithMaterial(ref barUnderSeatRight, currentMatName);
            AddEntityWithMaterial(ref barUnderSeatFront, currentMatName);
            AddEntityWithMaterial(ref barUnderSeatBack, currentMatName);

            //
            // Build the two cylinders on the sides
            //
            double CylinderRadius = legWidth / 3;
            double cylinderY      = 14.5;
            Mesh   leftCylinder   = MakeCylinder(CylinderRadius, seatDepth - 2 * legDepth, 16);

            leftCylinder.ApplyMaterial(currentMatName, textureMappingType.Cylindrical, .25, 1);
            leftCylinder.Rotate(Math.PI / 2, new Vector3D(0, 1, 0));
            leftCylinder.Translate(legDepth, legWidth / 2, cylinderY);

            model1.Entities.Add(leftCylinder);

            Mesh rightCylinder = (Mesh)leftCylinder.Clone();

            rightCylinder.Translate(0, seatWidth - legWidth, 0);

            model1.Entities.Add(rightCylinder);


            //
            //  Build the chair back
            //
            double chairBackHorizHeight = 4;
            double chairBackHorizDepth  = 2;
            double horizHeight1         = seatY + seatHeight + 7;
            Mesh   chairBackHorizontal1 = MakeBox(seatWidth - 2 * legWidth, chairBackHorizDepth, chairBackHorizHeight);

            chairBackHorizontal1.Translate((legDepth - chairBackHorizDepth) / 2.0, legWidth, horizHeight1);

            double cylinderHeight       = 12;
            double horizHeight2         = cylinderHeight + chairBackHorizHeight;
            Mesh   chairBackHorizontal2 = (Mesh)chairBackHorizontal1.Clone();

            chairBackHorizontal2.Translate(0, 0, horizHeight2);

            AddEntityWithMaterial(ref chairBackHorizontal1, currentMatName);
            AddEntityWithMaterial(ref chairBackHorizontal2, currentMatName);

            double chairBackCylinderRadius = chairBackHorizDepth / 4.0;
            double chairBackCylinderHeight = horizHeight2 - chairBackHorizHeight;
            Mesh   chairBackCylinder       = MakeCylinder(chairBackCylinderRadius, chairBackCylinderHeight, 16);

            chairBackCylinder.Translate(legDepth / 2.0, legWidth, horizHeight1 + chairBackHorizHeight);

            double chairBackWidth = seatWidth - 2 * legWidth;
            double cylinderOffset = 7;
            int    nCylinders     = (int)(chairBackWidth / cylinderOffset);
            double offset         = (chairBackWidth - (nCylinders + 1) * cylinderOffset) / 2.0;

            offset += cylinderOffset;

            for (int i = 0; i < nCylinders; i++, offset += cylinderOffset)
            {
                Mesh cyl = (Mesh)chairBackCylinder.Clone();
                cyl.ApplyMaterial(currentMatName, textureMappingType.Cylindrical, .25, 1);
                cyl.Translate(0, offset, 0);
                model1.Entities.Add(cyl);
            }

            //
            // Add the linear dimension
            //
            Point3D dimCorner = new Point3D(0, 0, legHeight);
            Plane   myPlane   = Plane.YZ;

            myPlane.Origin = dimCorner;

            LinearDim ad = new LinearDim(myPlane, new Point3D(0, 0, legHeight + 1), new Point3D(0, seatWidth, legHeight + 1), new Point3D(seatDepth + 10, seatWidth / 2, legHeight + 10), 3);

            ad.TextSuffix = " cm";
            model1.Entities.Add(ad);

            model1.Entities.UpdateBoundingBox();

            //
            // Update extents
            //
            widthTextBox.Text  = model1.Entities.BoxSize.X.ToString("f2") + " cm";
            depthTextBox.Text  = model1.Entities.BoxSize.Y.ToString("f2") + " cm";
            heightTextBox.Text = model1.Entities.BoxSize.Z.ToString("f2") + " cm";

            //
            // Update weight
            //
            double totalWeight = CalcWeight();

            weightTextBox.Text = totalWeight.ToString("f2") + " kg";

            //
            // Product ID label
            //
            devDept.Eyeshot.Labels.LeaderAndText prodIdLabel = new LeaderAndText(seatDepth / 2, seatWidth, 25, "Product ID goes here", new Font("Tahoma", 8.25f), System.Drawing.Color.Black, new Vector2D(20, 0));
            model1.Labels.Add(prodIdLabel);
        }
Ejemplo n.º 26
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));
        }
Ejemplo n.º 27
0
        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;
        }
Ejemplo n.º 28
0
        public Block CreateRocketBlock()
        {
            Block rocketBlock = new Block("Rocket");

            // missile bottom
            LinearPath lpMissileBottom = new LinearPath(
                new Point3D(0, 0, 1), new Point3D(1.5, 0, 1), new Point3D(1.5, 0, 1.5),
                new Point3D(0, 0, 1.5), new Point3D(0, 0, 1));

            Mesh missileBottom = lpMissileBottom.RevolveAsMesh(0, 2 * Math.PI, new Vector3D(0, 0, 1), new Point3D(0, 0, 1), 20, 0.1, Mesh.natureType.Smooth);

            missileBottom.ColorMethod = colorMethodType.byEntity;
            missileBottom.Color       = Color.Red;
            missileBottom.Weld();
            rocketBlock.Entities.Add(missileBottom);

            // missile body
            LinearPath lpMissileBody = new LinearPath(
                new Point3D(0, 0, 1.5), new Point3D(1.5, 0, 1.5),
                new Point3D(1.95, 0, 3.5), new Point3D(2.15, 0, 4.25),
                new Point3D(2.25, 0, 5.75), new Point3D(2.25, 0, 7.25),
                new Point3D(2.15, 0, 8.75), new Point3D(1.95, 0, 10.25),
                new Point3D(1.75, 0, 11), new Point3D(1.15, 0, 13),
                new Point3D(0, 0, 13), new Point3D(0, 0, 0)
                );

            Mesh missileBody = lpMissileBody.RevolveAsMesh(0, 2 * Math.PI, new Vector3D(0, 0, 1), new Point3D(0, 0, 1.5), 20, 0.1, Mesh.natureType.Smooth);

            missileBody.ColorMethod = colorMethodType.byEntity;
            missileBody.Color       = Color.White;
            missileBody.Weld();
            rocketBlock.Entities.Add(missileBody);

            // missile edge
            LinearPath lpMissileEdge = new LinearPath(
                new Point3D(0, 0, 13), new Point3D(1.15, 0, 13),
                new Point3D(0.85, 0, 13.5), new Point3D(0.65, 0, 13.75),
                new Point3D(0.45, 0, 13.85), new Point3D(0.25, 0, 13.92),
                new Point3D(0.05, 0, 13.992),
                new Point3D(0, 0, 14), new Point3D(0, 0, 14)
                );

            Mesh missileEdge = lpMissileEdge.RevolveAsMesh(0, 2 * Math.PI, new Vector3D(0, 0, 1), new Point3D(0, 0, 11), 50, 0.1, Mesh.natureType.Smooth);

            missileEdge.ColorMethod = colorMethodType.byEntity;
            missileEdge.Color       = Color.Red;
            missileEdge.Weld();
            rocketBlock.Entities.Add(missileEdge);

            // missile wings
            LinearPath lpMissileWing = new LinearPath(
                new Point3D(2.15, 0, 4.25), new Point3D(4, 0, 2),
                new Point3D(4, 0, 0), new Point3D(1.5, 0, 1.5),
                new Point3D(1.95, 0, 3.5), new Point3D(2.15, 0, 4.25)
                );

            devDept.Eyeshot.Entities.Region regionWing = new devDept.Eyeshot.Entities.Region(lpMissileWing, Plane.XZ);
            Mesh missileWing1 = regionWing.ExtrudeAsMesh(0.15, 0.1, Mesh.natureType.Plain);

            missileWing1.ColorMethod = colorMethodType.byEntity;
            missileWing1.Color       = Color.Red;
            missileWing1.Weld();
            rocketBlock.Entities.Add(missileWing1);

            Mesh missileWing2 = (Mesh)missileWing1.Clone();

            missileWing2.Rotate(Math.PI / 2, Vector3D.AxisZ);
            rocketBlock.Entities.Add(missileWing2);

            Mesh missileWing3 = (Mesh)missileWing2.Clone();

            missileWing3.Rotate(Math.PI / 2, Vector3D.AxisZ);
            rocketBlock.Entities.Add(missileWing3);

            Mesh missileWing4 = (Mesh)missileWing3.Clone();

            missileWing4.Rotate(Math.PI / 2, Vector3D.AxisZ);
            rocketBlock.Entities.Add(missileWing4);

            return(rocketBlock);
        }
Ejemplo n.º 29
0
        protected override void OnContentRendered(EventArgs e)
        {
            model1.AutoHideLabels = true;

            model1.GetGrid().AutoSize = true;
            model1.GetGrid().Step     = 100;

            string concreteMatName = "Concrete";
            string steelMatName    = "Blue steel";

            model1.Materials.Add(new Material(concreteMatName, System.Drawing.Color.FromArgb(25, 25, 25), System.Drawing.Color.LightGray, System.Drawing.Color.FromArgb(31, 31, 31), .05f, 0));
            model1.Materials.Add(new Material(steelMatName, System.Drawing.Color.RoyalBlue));

            // square column block
            Block b = new Block("squareCol");

            // creates a gray box
            Mesh m1 = Mesh.CreateBox(30, 30, 270);

            m1.ColorMethod  = colorMethodType.byEntity;
            m1.Color        = System.Drawing.Color.Gray;
            m1.MaterialName = concreteMatName;

            // adds it to the block
            b.Entities.Add(m1);

            // creates a new black polyline
            LinearPath steel = new LinearPath();

            steel.Vertices    = new Point3D[8];
            steel.Vertices[0] = new Point3D(4, 4, -20);
            steel.Vertices[1] = new Point3D(4, 4, 290);
            steel.Vertices[2] = new Point3D(4, 26, 290);
            steel.Vertices[3] = new Point3D(4, 26, -20);
            steel.Vertices[4] = new Point3D(26, 26, -20);
            steel.Vertices[5] = new Point3D(26, 26, 290);
            steel.Vertices[6] = new Point3D(26, 4, 290);
            steel.Vertices[7] = new Point3D(26, 4, -20);

            steel.ColorMethod = colorMethodType.byEntity;
            steel.Color       = System.Drawing.Color.Black;

            // adds it to the block
            b.Entities.Add(steel);

            // creates a price tag
            devDept.Eyeshot.Entities.Attribute at = new devDept.Eyeshot.Entities.Attribute(new Point3D(0, -15), "Price", "$25,000", 10);

            // adds it to the block
            b.Entities.Add(at);

            // adds the block to the master block dictionary
            model1.Blocks.Add(b);

            // inserts the "SquareCol" block many times: this is a HUGE memory and graphic resources saving for big models
            BlockReference reference;

            for (int k = 0; k < 4; k++)
            {
                for (int j = 0; j < 5; j++)
                {
                    for (int i = 0; i < 5; i++)
                    {
                        if (i < 2 && j < 2)
                        {
                            System.Diagnostics.Debug.WriteLine("No columns here");
                        }

                        else
                        {
                            reference = new BlockReference(i * 500, j * 400, k * 300, "squareCol", 1, 1, 1, 0);

                            // defines a different price for each one
                            reference.Attributes.Add("Price", "$" + i + ",000");

                            model1.Entities.Add(reference);
                        }
                    }
                }
            }

            // again as above
            b = new Block("floor");

            double width = 2030;
            double depth = 1630;
            double dimA  = 1000;
            double dimB  = 800;

            Point2D[] outerPoints = new Point2D[7];

            outerPoints[0] = new Point2D(0, dimB);
            outerPoints[1] = new Point2D(dimA, dimB);
            outerPoints[2] = new Point2D(dimA, 0);
            outerPoints[3] = new Point2D(width, 0);
            outerPoints[4] = new Point2D(width, depth);
            outerPoints[5] = new Point2D(0, depth);
            outerPoints[6] = (Point2D)outerPoints[0].Clone();

            LinearPath outer = new LinearPath(Plane.XY, outerPoints);

            Point2D[] innerPoints = new Point2D[5];

            innerPoints[0] = new Point2D(1530, 800);
            innerPoints[1] = new Point2D(1530, 950);
            innerPoints[2] = new Point2D(1650, 950);
            innerPoints[3] = new Point2D(1650, 800);
            innerPoints[4] = (Point2D)innerPoints[0].Clone();

            LinearPath inner = new LinearPath(Plane.XY, innerPoints);

            devDept.Eyeshot.Entities.Region reg = new devDept.Eyeshot.Entities.Region(outer, inner);

            Mesh m2 = reg.ExtrudeAsMesh(30, 0.1, Mesh.natureType.Plain);

            m2.ColorMethod  = colorMethodType.byEntity;
            m2.Color        = System.Drawing.Color.White;
            m2.MaterialName = concreteMatName;

            b.Entities.Add(m2);

            model1.Blocks.Add(b);

            for (int i = 0; i < 4; i++)
            {
                reference = new BlockReference(0, 0, 270 + i * 300, "floor", 1, 1, 1, 0);

                model1.Entities.Add(reference);
            }

            string brickMatName = "Wall bricks";

            model1.Materials.Add(new Material(brickMatName, new Bitmap("../../../../../../dataset/Assets/Textures/Bricks.jpg")));

            b = new Block("brickWall");

            Mesh rm = Mesh.CreateBox(470, 30, 270, Mesh.natureType.RichPlain);

            rm.ApplyMaterial(brickMatName, textureMappingType.Cubic, 1.5, 1.5);

            rm.ColorMethod = colorMethodType.byEntity;
            rm.Color       = System.Drawing.Color.Chocolate;

            b.Entities.Add(rm);

            model1.Blocks.Add(b);

            for (int j = 1; j < 4; j++)
            {
                for (int i = 0; i < 2; i++)
                {
                    reference = new BlockReference(1030 + i * 500, 0, j * 300, "brickWall", 1, 1, 1, 0);

                    model1.Entities.Add(reference);
                }
            }


            // Cylindrical column
            b = new Block("CylindricalCol");

            Mesh m3 = Mesh.CreateCylinder(20, 270, 32, Mesh.natureType.Smooth);

            m3.ColorMethod  = colorMethodType.byEntity;
            m3.Color        = System.Drawing.Color.RoyalBlue;
            m3.MaterialName = steelMatName;

            b.Entities.Add(m3);

            model1.Blocks.Add(b);

            for (int j = 0; j < 2; j++)
            {
                for (int i = 0; i < 3; i++)
                {
                    reference = new BlockReference(100 + i * 400, 115 + j * 200, 0, "CylindricalCol", 1, 1, 1, 0);

                    model1.Entities.Add(reference);
                }
            }

            // Roof (not a block this time)
            Mesh roof = Mesh.CreateBox(880, 280, 30);

            // Edits vertices to add a slope
            roof.Vertices[4].Z = 15;
            roof.Vertices[7].Z = 15;

            roof.Translate(60, 75, 270);

            model1.Entities.Add(roof, System.Drawing.Color.DimGray);


            // Labels
            LeaderAndText lat = new LeaderAndText(new Point3D(0, 800, 1200),
                                                  "Height = 12 m", new System.Drawing.Font("Tahoma", 8.25f), System.Drawing.Color.White, new Vector2D(0, 20));

            lat.FillColor = System.Drawing.Color.Black;
            model1.Labels.Add(lat);


            LeaderAndText ff;

            ff = new LeaderAndText(new Point3D(1000, 1000, 300),
                                   "First floor", new System.Drawing.Font("Tahoma", 8.25f), System.Drawing.Color.White, new Vector2D(0, 10));

            ff.FillColor = System.Drawing.Color.Red;
            ff.Alignment = System.Drawing.ContentAlignment.BottomCenter;

            model1.Labels.Add(ff);

            // fits the model in the viewport
            model1.ZoomFit();

            // refresh the viewport
            model1.Invalidate();

            base.OnContentRendered(e);
        }
Ejemplo n.º 30
0
        public static void Primitives(Model model)
        {
            model.GetGrid().Step = 25;
            model.GetGrid().Min.X = -25;
            model.GetGrid().Min.Y = -25;

            model.GetGrid().Max.X = 125;
            model.GetGrid().Max.Y = 175;

            double deltaOffset = 50;
            double offsetX     = 0;
            double offsetY     = 0;

            // First Row

            // Box
            Mesh mesh = Mesh.CreateBox(40, 40, 30);

            mesh.Translate(-20, -20, 0);
            model.Entities.Add(mesh, Color.GreenYellow);
            offsetX += deltaOffset;

            // Cone
            mesh = Mesh.CreateCone(20, 10, 30, 30, Mesh.natureType.Smooth);
            mesh.Translate(offsetX, offsetY, 0);
            model.Entities.Add(mesh, Color.GreenYellow);
            offsetX += deltaOffset;

            mesh = Mesh.CreateCone(20, 0, 30, 30, Mesh.natureType.Smooth);
            mesh.Translate(offsetX, offsetY, 0);
            model.Entities.Add(mesh, Color.GreenYellow);
            offsetX += deltaOffset;

            // Second Row
            offsetX  = 0;
            offsetY += deltaOffset;

            mesh = Mesh.CreateCone(10, 20, 30, 30, Mesh.natureType.Smooth);
            mesh.Translate(offsetX, offsetY, 0);
            model.Entities.Add(mesh, Color.GreenYellow);
            offsetX += deltaOffset;

            mesh = Mesh.CreateCone(20, 10, 30, 3, Mesh.natureType.Smooth);
            mesh.Translate(offsetX, offsetY, 0);
            model.Entities.Add(mesh, Color.GreenYellow);
            offsetX += deltaOffset;

            // Sphere
            mesh = Mesh.CreateSphere(20, 3, 3, Mesh.natureType.Smooth);
            mesh.Translate(offsetX, offsetY, 0);
            model.Entities.Add(mesh, Color.GreenYellow);

            // Third Row
            offsetX  = 0;
            offsetY += deltaOffset;

            mesh = Mesh.CreateSphere(20, 8, 6, Mesh.natureType.Smooth);
            mesh.Translate(offsetX, offsetY, 0);
            model.Entities.Add(mesh, Color.GreenYellow);
            offsetX += deltaOffset;

            mesh = Mesh.CreateSphere(20, 14, 14, Mesh.natureType.Smooth);
            mesh.Translate(offsetX, offsetY, 0);
            model.Entities.Add(mesh, Color.GreenYellow);
            offsetX += deltaOffset;

            mesh = Mesh.CreateTorus(18, 5, 15, 17, Mesh.natureType.Smooth);
            mesh.Translate(offsetX, offsetY, 0);
            model.Entities.Add(mesh, Color.GreenYellow);
            offsetX += deltaOffset;

            // Fourth Row
            offsetX  = 0;
            offsetY += deltaOffset;

            LinearPath lp = LinearPath.CreateHelix(10, 5.3, 10.7, true, 0.25);

            lp.Translate(offsetX, offsetY, 0);
            model.Entities.Add(lp, Draw.Color);
            offsetX += deltaOffset;

            mesh           = Mesh.CreateSpring(10, 2, 16, 24, 10, 6, true, true, Mesh.natureType.Smooth);
            mesh.EdgeStyle = Mesh.edgeStyleType.None;
            mesh.Translate(offsetX, offsetY, 0);
            model.Entities.Add(mesh, Color.GreenYellow);
            offsetX += deltaOffset;

            // Sweep
            double z      = 30;
            double radius = 15;

            Line l1 = new Line(0, 0, 0, 0, 0, z);
            Arc  a1 = new Arc(new Point3D(radius, 0, z), new Point3D(0, 0, z), new Point3D(radius, 0, z + radius));
            Line l2 = new Line(radius, 0, z + radius, 30, 0, z + radius);

            CompositeCurve composite = new CompositeCurve(l1, a1, l2);
            LinearPath     lpOuter   = new LinearPath(10, 16);
            LinearPath     lpInner   = new LinearPath(5, 11);

            lpInner.Translate(2.5, 2.5, 0);
            lpInner.Reverse();

            Region reg = new Region(lpOuter, lpInner);

            mesh = reg.SweepAsMesh(composite, .25);
            mesh.Translate(offsetX - 10, offsetY - 8, 0);
            model.Entities.Add(mesh, Color.GreenYellow);
        }