Beispiel #1
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);
        }
Beispiel #2
0
        public void Primitives()
        {
            model1.GetGrid().Step = 25;
            model1.GetGrid().Min.X = -25;
            model1.GetGrid().Min.Y = -25;

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

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

            System.Drawing.Color color = System.Drawing.Color.SlateGray;

            // First Row

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

            mesh.Translate(-20, -20, 0);
            model1.Entities.Add(mesh, color);
            offsetX += deltaOffset;

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

            // second cone
            mesh = Mesh.CreateCone(20, 0, 30, 30, Mesh.natureType.Smooth);
            mesh.Translate(offsetX, offsetY, 0);
            model1.Entities.Add(mesh, color);
            offsetX += deltaOffset;

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

            // Cylinder
            mesh = Mesh.CreateCylinder(15, 25, 20, Mesh.natureType.Smooth);
            mesh.Translate(offsetX, offsetY, 0);
            model1.Entities.Add(mesh, color);
            offsetX += deltaOffset;

            // prism
            mesh = Mesh.CreateCone(20, 10, 30, 3, Mesh.natureType.Smooth);
            mesh.Translate(offsetX, offsetY, 0);
            model1.Entities.Add(mesh, color);
            offsetX += deltaOffset;

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

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

            // sphere
            mesh = Mesh.CreateSphere(20, 8, 6, Mesh.natureType.Smooth);
            mesh.Translate(offsetX, offsetY, 0);
            model1.Entities.Add(mesh, color);
            offsetX += deltaOffset;

            // second sphere
            mesh = Mesh.CreateSphere(20, 50, 50, Mesh.natureType.Smooth);
            mesh.Translate(offsetX, offsetY, 0);
            model1.Entities.Add(mesh, color);
            offsetX += deltaOffset;

            // torus
            mesh = Mesh.CreateTorus(18, 5, 15, 17, Mesh.natureType.Smooth);
            mesh.Translate(offsetX, offsetY, 0);
            model1.Entities.Add(mesh, color);
            offsetX += deltaOffset;

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

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

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

            devDept.Eyeshot.Entities.Line l1 = new devDept.Eyeshot.Entities.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));

            devDept.Eyeshot.Entities.Line l2 = new devDept.Eyeshot.Entities.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 profile = new Region(lpOuter, lpInner);

            mesh = profile.SweepAsMesh(composite, 0.1);
            mesh.Translate(offsetX - 10, offsetY - 8, 0);
            model1.Entities.Add(mesh, color);

            // Hexagon with hole region revolved
            offsetX += deltaOffset;

            LinearPath lp = new LinearPath(7);

            for (int i = 0; i <= 360; i += 60)
            {
                lp.Vertices[i / 60] = new Point3D(10 * Math.Cos(Utility.DegToRad(i)), 10 * Math.Sin(Utility.DegToRad(i)), 0);
            }

            Circle circle = new Circle(new Point3D(0, 0, 0), 7);

            circle.Reverse();

            Region profile2 = new Region(lp, circle);

            mesh = profile2.RevolveAsMesh(0, Utility.DegToRad(10), Vector3D.AxisX, new Point3D(0, -60, 0), Utility.NumberOfSegments(60, Math.PI / 6, 0.1), 0.1, Mesh.natureType.Smooth); mesh.FlipNormal();
            mesh.Scale(2, 2, 2);

            mesh.Translate(offsetX, offsetY, 0);
            mesh.EdgeStyle      = Mesh.edgeStyleType.Sharp;
            mesh.SmoothingAngle = Utility.DegToRad(59);
            model1.Entities.Add(mesh, color);
        }