Esempio n. 1
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();
        }
Esempio n. 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);
        }