Example #1
0
 private void generateHoleMilling(IGeometryOutput sb)
 {
     sb.BeginGroup("generateHoleMilling");
     float dia = (float)(work.mainMill.diameter * 0.5);
     sb.MoveTo(new PointF(0, dia));
     sb.SetDepth(0);
     double pd = 0;
     bool running = true;
     while (running)
     {
         pd += work.mainMill.passDepth;
         if (pd >= work.dimensions.stockThickness + cutThroughMargin)
         {
             pd = work.dimensions.stockThickness;
             running = false;
         }
         sb.SetDepth((float)-pd);
         sb.ArcTo(new PointF(0, dia), new PointF(0, 0), false);
         sb.SetDepth(0);
     }
     sb.SetDepth((float)-(work.dimensions.stockThickness + cutThroughMargin));
     sb.ArcTo(new PointF(0, dia), new PointF(0, 0), false);
     sb.SetDepth(0);
     sb.SetDepth(0.1f);
     sb.EndGroup();
 }
Example #2
0
        private void generateHoleMilling(IGeometryOutput sb)
        {
            sb.BeginGroup("generateHoleMilling");
            float dia = (float)(work.mainMill.diameter * 0.5);

            sb.MoveTo(new PointF(0, dia));
            sb.SetDepth(0);
            double pd      = 0;
            bool   running = true;

            while (running)
            {
                pd += work.mainMill.passDepth;
                if (pd >= work.dimensions.stockThickness + cutThroughMargin)
                {
                    pd      = work.dimensions.stockThickness;
                    running = false;
                }
                sb.SetDepth((float)-pd);
                sb.ArcTo(new PointF(0, dia), new PointF(0, 0), false);
                sb.SetDepth(0);
            }
            sb.SetDepth((float)-(work.dimensions.stockThickness + cutThroughMargin));
            sb.ArcTo(new PointF(0, dia), new PointF(0, 0), false);
            sb.SetDepth(0);
            sb.SetDepth(0.1f);
            sb.EndGroup();
        }
Example #3
0
        private void generateToothTopMilling(IGeometryOutput sb)
        {
            double cDep = work.dimensions.stockThickness - work.dimensions.plateThickness -
                          work.dimensions.toothThickness;

            if (cDep <= 0)
            {
                return;
            }
            sb.BeginGroup("generateToothTopMilling");
            double iRad = work.calc.radius - work.calc.dedendum - work.dimensions.ridgeMargin
                          + work.mainMill.diameter * 0.5f;
            double oRad = work.calc.radius + work.calc.addendum + work.dimensions.plateMargin +
                          work.mainMill.diameter * 0.5f;

            if (oRad < iRad)
            {
                oRad = iRad;
            }
            sb.SetDepth(0.1f);
            sb.MoveTo(new PointF(0, (float)iRad));
            double rDep = cDep - work.dimensions.ridgeThickness;

            sb.SetDepth((float)-rDep);
            for (double d = rDep; d < cDep;)
            {
                d += work.mainMill.passDepth;
                if (d > cDep)
                {
                    d = cDep;
                }
                //  plunge slowly
                sb.SetDepth((float)-d);
                bool running = true;
                bool first   = true;
                for (double r = iRad; running; r += work.mainMill.stepOver)
                {
                    if (r >= oRad)
                    {
                        r       = oRad;
                        running = false;
                    }
                    bool clockwise = true;
                    if (first)
                    {
                        clockwise = false;
                        first     = false;
                    }
                    sb.LineTo(new PointF(0, (float)r));
                    sb.ArcTo(new PointF(0, (float)r), new PointF(0, 0), clockwise);
                }
            }
            sb.SetDepth(0);
            sb.SetDepth(0.1f);
            sb.EndGroup();
        }
Example #4
0
 private void generatePrefix(IGeometryOutput sb, MillInfo mill)
 {
     sb.BeginGroup("generatePrefix");
     sb.Comment(String.Format("Diameter {0} Cut Depth {1} Pass Depth {2} Feed {3} Speed {4}",
                              mill.diameter, mill.cuttingDepth, mill.passDepth, mill.feed, mill.speed));
     sb.SetFeed((float)mill.feed);
     sb.SetSpeed((float)mill.speed);
     sb.SetDepth(0.5f);
     sb.MoveTo(new PointF(0, 0));
     sb.SetDepth(0.1f);
     sb.EndGroup();
 }
Example #5
0
 private void generatePrefix(IGeometryOutput sb, MillInfo mill)
 {
     sb.BeginGroup("generatePrefix");
     sb.Comment(String.Format("Diameter {0} Cut Depth {1} Pass Depth {2} Feed {3} Speed {4}",
         mill.diameter, mill.cuttingDepth, mill.passDepth, mill.feed, mill.speed));
     sb.SetFeed((float)mill.feed);
     sb.SetSpeed((float)mill.speed);
     sb.SetDepth(0.5f);
     sb.MoveTo(new PointF(0, 0));
     sb.SetDepth(0.1f);
     sb.EndGroup();
 }
Example #6
0
        public string generateToothMill()
        {
            if (!work.useToothMill)
            {
                return(null);
            }
            IGeometryOutput output = MakeOutput();

            generatePrefix(output, work.toothMill);
            generateToothProfileMilling(output, work.numTeeth, work.toothMill);
            generateSuffix(output);
            return(output.Finish());
        }
Example #7
0
        public string generateMainMill(bool includeTooth)
        {
            IGeometryOutput output = MakeOutput();

            generatePrefix(output, work.mainMill);
            generateHoleMilling(output);
            generateRidgeTopMilling(output);
            generateFaceMilling(output);
            generateToothTopMilling(output);
            generateToothOutlineMilling(output);
            if (includeTooth)
            {
                generateToothProfileMilling(output, work.numTeeth, work.mainMill);
            }
            generateSuffix(output);
            return(output.Finish());
        }
Example #8
0
        private void generateToothProfileMilling(IGeometryOutput sb, int teeth, MillInfo mill)
        {
            sb.BeginGroup("generateToothProfileMilling");
            Outline nuProfile = GenerateOutline(work.profile, teeth, mill.diameter);
            PointF  start     = nuProfile.points[0];
            double  cDep      = work.dimensions.stockThickness - work.dimensions.plateThickness;
            double  rDep      = cDep - work.dimensions.toothThickness;

            sb.MoveTo(start);
            sb.SetDepth((float)-rDep);
            PointF curPos   = start;
            double endDepth = cDep;

            if (work.dimensions.plateThickness == 0)
            {
                endDepth += cutThroughMargin;
            }
            sb.Comment(String.Format("startDepth {0} endDepth {1} passDepth {2}",
                                     rDep, endDepth, mill.passDepth));
            for (double d = rDep; d < endDepth;)
            {
                d += mill.passDepth;
                if (d > endDepth)
                {
                    d = endDepth;
                }
                //  plunge slowly
                sb.SetDepth((float)-d);
                foreach (PointF p in nuProfile.points)
                {
                    curPos = LineOrArc(sb, p, curPos);
                }
                LineOrArc(sb, start, curPos);
                curPos = start;
            }
            sb.SetDepth(0);
            sb.SetDepth(0.1f);
            sb.EndGroup();
        }
Example #9
0
        PointF LineOrArc(IGeometryOutput sb, PointF p, PointF curPos)
        {
            float sz = Distance2(p, curPos);

            if (sz < 9e-8)
            {
                return(curPos);
            }
            float  dl = Math.Abs(Length2(p) - Length2(curPos));
            double a1 = Math.Atan2(p.Y, p.X);
            double a2 = Math.Atan2(curPos.Y, curPos.X);

            if (a1 < a2 - Math.PI)
            {
                a1 += 2 * Math.PI;
            }
            else if (a1 > a2 + Math.PI)
            {
                a1 -= 2 * Math.PI;
            }
            bool clockwise = false;

            if (a1 < a2)
            {
                clockwise = true;
            }
            if (dl < 1e-3 && dl < sz * 0.125f && sz > 4e-6)
            {
                sb.ArcTo(p, new PointF(0, 0), clockwise);
            }
            else
            {
                sb.LineTo(p);
            }
            return(p);
        }
Example #10
0
 private void generateFaceMilling(IGeometryOutput sb)
 {
     sb.BeginGroup("generateFaceMilling");
     sb.Comment("TODO: implement face milling");
     sb.EndGroup();
 }
Example #11
0
 private void generateSuffix(IGeometryOutput sb)
 {
     sb.BeginGroup("generateSuffix");
     sb.SetDepth(0.5f);
     sb.EndGroup();
 }
Example #12
0
 PointF LineOrArc(IGeometryOutput sb, PointF p, PointF curPos)
 {
     float sz = Distance2(p, curPos);
     if (sz < 9e-8)
     {
         return curPos;
     }
     float dl = Math.Abs(Length2(p) - Length2(curPos));
     double a1 = Math.Atan2(p.Y, p.X);
     double a2 = Math.Atan2(curPos.Y, curPos.X);
     if (a1 < a2 - Math.PI)
     {
         a1 += 2 * Math.PI;
     }
     else if (a1 > a2 + Math.PI)
     {
         a1 -= 2 * Math.PI;
     }
     bool clockwise = false;
     if (a1 < a2)
     {
         clockwise = true;
     }
     if (dl < 1e-3 && dl < sz * 0.125f && sz > 4e-6)
     {
         sb.ArcTo(p, new PointF(0, 0), clockwise);
     }
     else
     {
         sb.LineTo(p);
     }
     return p;
 }
Example #13
0
 private void generateToothProfileMilling(IGeometryOutput sb, int teeth, MillInfo mill)
 {
     sb.BeginGroup("generateToothProfileMilling");
     Outline nuProfile = GenerateOutline(work.profile, teeth, mill.diameter);
     PointF start = nuProfile.points[0];
     double cDep = work.dimensions.stockThickness - work.dimensions.plateThickness;
     double rDep = cDep - work.dimensions.toothThickness;
     sb.MoveTo(start);
     sb.SetDepth((float)-rDep);
     PointF curPos = start;
     double endDepth = cDep;
     if (work.dimensions.plateThickness == 0)
     {
         endDepth += cutThroughMargin;
     }
     sb.Comment(String.Format("startDepth {0} endDepth {1} passDepth {2}",
         rDep, endDepth, mill.passDepth));
     for (double d = rDep; d < endDepth; )
     {
         d += mill.passDepth;
         if (d > endDepth)
         {
             d = endDepth;
         }
         //  plunge slowly
         sb.SetDepth((float)-d);
         foreach (PointF p in nuProfile.points)
         {
             curPos = LineOrArc(sb, p, curPos);
         }
         LineOrArc(sb, start, curPos);
         curPos = start;
     }
     sb.SetDepth(0);
     sb.SetDepth(0.1f);
     sb.EndGroup();
 }
Example #14
0
 private void generatePlateMilling(IGeometryOutput sb)
 {
     if (work.dimensions.plateThickness <= 0)
     {
         return;
     }
     double cDep = work.dimensions.stockThickness;
     if (cDep <= 0)
     {
         return;
     }
     sb.BeginGroup("generatePlateMilling");
     double iRad = work.calc.radius + work.calc.addendum
             + work.mainMill.diameter * 0.5f;
     double oRad = work.calc.radius + work.calc.addendum + work.dimensions.plateMargin
             + work.mainMill.diameter * 0.5f;
     if (oRad < iRad)
     {
         oRad = iRad;
     }
     sb.SetDepth(0.1f);
     sb.MoveTo(new PointF(0, (float)iRad));
     double rDep = cDep - work.dimensions.plateThickness;
     sb.SetDepth((float)-rDep);
     for (double d = rDep; d < cDep; )
     {
         d += work.mainMill.passDepth;
         if (d > cDep)
         {
             d = cDep;
         }
         //  plunge slowly
         sb.SetDepth((float)-d);
         bool running = true;
         bool first = true;
         for (double r = iRad; running; r += work.mainMill.stepOver)
         {
             if (r >= oRad)
             {
                 r = oRad;
                 running = false;
             }
             bool clockwise = true;
             if (first)
             {
                 clockwise = false;
                 first = false;
             }
             if (work.dimensions.stockThickness - tabHeight < d
                 && r > oRad - work.mainMill.stepOver)
             {
                 //  mill with tabs
                 sb.Comment("todo: mill with tabs");
             }
             sb.LineTo(new PointF(0, (float)r));
             sb.ArcTo(new PointF(0, (float)r), new PointF(0, 0), clockwise);
         }
     }
     sb.SetDepth(0);
     sb.SetDepth(0.1f);
     sb.EndGroup();
 }
Example #15
0
 private void generateSuffix(IGeometryOutput sb)
 {
     sb.BeginGroup("generateSuffix");
     sb.SetDepth(0.5f);
     sb.EndGroup();
 }
Example #16
0
 private void generateFaceMilling(IGeometryOutput sb)
 {
     sb.BeginGroup("generateFaceMilling");
     sb.Comment("TODO: implement face milling");
     sb.EndGroup();
 }
Example #17
0
 private void generateRidgeTopMilling(IGeometryOutput sb)
 {
     double cDep = work.dimensions.stockThickness - work.dimensions.plateThickness -
         work.dimensions.toothThickness - work.dimensions.ridgeThickness;
     if (cDep <= 0)
     {
         return;
     }
     sb.BeginGroup("generateRidgeTopMilling");
     double iRad = work.calc.radius - work.calc.dedendum - work.dimensions.ridgeMargin -
             work.dimensions.ridgeThickness + work.mainMill.diameter * 0.5f;
     double oRad = work.calc.radius + work.calc.addendum + work.dimensions.plateMargin +
             work.mainMill.diameter * 0.5f;
     if (oRad < iRad)
     {
         oRad = iRad;
     }
     sb.SetDepth(0.1f);
     sb.MoveTo(new PointF(0, (float)iRad));
     sb.SetDepth(0);
     for (double d = 0; d < cDep;)
     {
         d += work.mainMill.passDepth;
         if (d > cDep)
         {
             d = cDep;
         }
         //  plunge slowly
         sb.SetDepth((float)-d);
         bool running = true;
         bool first = true;
         for (double r = iRad; running; r += work.mainMill.stepOver)
         {
             if (r >= oRad)
             {
                 r = oRad;
                 running = false;
             }
             bool clockwise = true;
             if (first)
             {
                 clockwise = false;
                 first = false;
             }
             sb.LineTo(new PointF(0, (float)r));
             sb.ArcTo(new PointF(0, (float)r), new PointF(0, 0), clockwise);
         }
     }
     sb.SetDepth(0);
     sb.SetDepth(0.1f);
     sb.EndGroup();
 }