示例#1
0
            protected override void WorkCompleted(Environment model)
            {
                model.Entities.Add(toolPath, "Default", Color.DarkBlue);

                #region Tool symbol definition

                Block b1 = new Block("ballTool");

                Circle c1 = new Circle(0, 0, 0, ballToolRadius);
                Circle c2 = new Circle(0, 0, 50, ballToolRadius);
                Arc    a1 = new Arc(0, 0, 0, ballToolRadius, Math.PI, 2 * Math.PI);
                a1.Rotate(Math.PI / 2, Vector3D.AxisX);
                Arc a2 = (Arc)a1.Clone();
                a2.Rotate(Math.PI / 2, Vector3D.AxisZ);

                Line l1 = new Line(-ballToolRadius, 0, 0, -ballToolRadius, 0, 50);

                b1.Entities.Add(c1);
                b1.Entities.Add(c2);
                b1.Entities.Add(a1);
                b1.Entities.Add(a2);
                b1.Entities.Add(l1);

                LinearPath lp1 = LinearPath.CreateHelix(ballToolRadius, 50, 1, false, .1);
                b1.Entities.Add(lp1);

                b1.Entities.Add(lp1);
                for (int i = 1; i < 4; i++)
                {
                    Line cloneLn = (Line)l1.Clone();
                    cloneLn.Rotate(i * Math.PI / 2, Vector3D.AxisZ);
                    b1.Entities.Add(cloneLn);
                }

                model.Blocks.Add(b1);

                #endregion

                // Adds a reference to the tool symbol
                model.Entities.Add(new BlockReference(toolPath.Vertices[toolPath.Vertices.Length - 1], "ballTool", 1, 1, 1, 0));

                model.ZoomFit();
            }
示例#2
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);
        }