コード例 #1
0
            protected override void DoWork(System.ComponentModel.BackgroundWorker worker, System.ComponentModel.DoWorkEventArgs doWorkEventArgs)
            {
                // body -------------------------

                if (!UpdateProgressAndCheckCancelled(1, totalSteps, "Body drawing", worker, doWorkEventArgs))
                {
                    return;
                }

                Surface s1 = DrawBody();

                whiteEntList.Add(s1);

                // body closure
                Arc     a5 = new Arc(80, 0, 0, 110, Math.PI, 1.11 * Math.PI);
                Surface s7 = a5.RevolveAsSurface(Math.PI, Math.PI, Vector3D.AxisX, Point3D.Origin)[0];

                whiteEntList.Add(s7);

                // fillet
                Surface[] f1;
                Surface.Fillet(s1, s7, 5, filletTol, true, true, true, true, true, false, out f1);

                whiteEntList.AddRange(f1);

                // handle ------------------------

                if (!UpdateProgressAndCheckCancelled(2, totalSteps, "Handle drawing", worker, doWorkEventArgs))
                {
                    return;
                }

                double len1 = 150;
                double ang1 = -Math.PI / 2.8;

                // back
                Arc a1 = new Arc(Plane.YZ, new Point2D(22, 0), 50, 4 * Math.PI / 5, Math.PI);

                Surface s2 = a1.ExtrudeAsSurface(len1, 0, 0)[0];

                s2.Rotate(ang1, Vector3D.AxisZ);

                whiteEntList.Add(s2);

                // front
                Arc a2 = new Arc(Plane.YZ, new Point2D(-30, 0), 30, 0, Math.PI / 5);
                Arc a3 = new Arc(Plane.YZ, new Point2D(-15, -40), 60, 9 * Math.PI / 20, 12 * Math.PI / 20);

                Arc a4;

                Curve.Fillet(a2, a3, 10, false, false, true, true, out a4);

                CompositeCurve cc1 = new CompositeCurve(a2, a4, a3);

                Surface s3 = cc1.ExtrudeAsSurface(len1, 0, 0)[0];

                s3.Rotate(ang1, Vector3D.AxisZ);

                whiteEntList.Add(s3);

                // bottom
                Line ln3 = new Line(0, -125, 100, -125);

                s2.Regen(0.1);

                Surface s6 = ln3.ExtrudeAsSurface(new Vector3D(0, 0, s2.BoxMax.Z), Utility.DegToRad(2), trimTol)[0];

                whiteEntList.Add(s6);


                // fillets ------------------------------
                if (!UpdateProgressAndCheckCancelled(3, totalSteps, "Computing fillets", worker, doWorkEventArgs))
                {
                    return;
                }

                Surface[] f2, f3, f4;

                // rear fillet
                Surface.Fillet(new Surface[] { s2 }, new Surface[] { s6 }, 10, filletTol, true, true, true, true, true, false, out f2);
                whiteEntList.AddRange(f2);



                // along handle fillet
                Surface.Fillet(new Surface[] { s3 }, new Surface[] { s2, s6, f2[0] }, 5, filletTol, true, true, true, true, true, false, out f3);
                whiteEntList.AddRange(f3);

                // handle-body fillet
                Surface.Fillet(new Surface[] { s1 }, new Surface[] { s3, s2, s6, f2[0], f3[0] }, 10, filletTol, false, false, true, true, true, false, out f4);

                foreach (Surface surface in f4)
                {
                    surface.ReverseU();
                }

                whiteEntList.AddRange(f4);

                // nozzle ------------------------
                Surface s8 = DrawNozzle(trimTol);

                darkEntList.Add(s8);

                // offset ------------------------

                if (!UpdateProgressAndCheckCancelled(4, totalSteps, "Computing offset", worker, doWorkEventArgs))
                {
                    return;
                }

                offsetEntList.AddRange(OffsetSurfaces(offsetAmount, offsetTol, whiteEntList));
                offsetEntList.AddRange(OffsetSurfaces(offsetAmount, offsetTol, darkEntList));

                // mirror ------------------------

                if (!UpdateProgressAndCheckCancelled(5, totalSteps, "Computing mirror", worker, doWorkEventArgs))
                {
                    return;
                }

                Mirror m = new Mirror(Plane.XY);

                MirrorEntities(m, whiteEntList);

                if (Cancelled(worker, doWorkEventArgs))
                {
                    return;
                }

                MirrorEntities(m, darkEntList);

                if (Cancelled(worker, doWorkEventArgs))
                {
                    return;
                }

                MirrorEntities(m, offsetEntList);

                if (Cancelled(worker, doWorkEventArgs))
                {
                    return;
                }
            }