public void CNCFileParser_ParseNCFile_PathNotNull()
        {
            string inputFile = "2-CELL-TEST.2.nc";

            ToolpathLib.ToolPath5Axis toolpath = ToolpathLib.CNCFileParser.CreatePath(inputFile);
            Assert.IsNotNull(toolpath);
        }
        public void CNCFileParser_ParseNCIFile_pathNotNull()
        {
            string inputFile = "SPLINE-CHANNEL-CONTOURPATH.NCI";

            ToolpathLib.ToolPath5Axis toolpath = ToolpathLib.CNCFileParser.CreatePath(inputFile);
            Assert.IsNotNull(toolpath);
        }
        public void CNCFileParser_ParseNCIFile_toolpathhasCorrectValues()
        {
            string inputFile = "SPLINE-CHANNEL-CONTOURPATH.NCI";

            ToolpathLib.ToolPath5Axis toolpath = ToolpathLib.CNCFileParser.CreatePath(inputFile);

            Assert.AreEqual(-3.876529, toolpath[0].Position.X, "Xentity0");
            Assert.AreEqual(0.05, toolpath[0].Position.Y, "Yentity0");
            Assert.AreEqual(3.307008, toolpath[0].Position.Z, "Zentity0");
            Assert.AreEqual(0, toolpath[0].Feedrate.Value, "Fentity0");
            Assert.IsFalse(toolpath[0].JetOn, "Jentity0");

            Assert.AreEqual(-3.876529, toolpath[1].Position.X, "Xentity1");
            Assert.AreEqual(0.05, toolpath[1].Position.Y, "Yentity1");
            Assert.AreEqual(1.407008, toolpath[1].Position.Z, "Zentity1");
            Assert.AreEqual(0, toolpath[1].Feedrate.Value, "Fentity1");
            Assert.IsFalse(toolpath[1].JetOn, "Jentity1");
            Assert.AreEqual(BlockType.Rapid, toolpath[1].Type, "type 1");

            Assert.AreEqual(-3.565848, toolpath[3].Position.X, "Xentity3");
            Assert.AreEqual(0.05, toolpath[3].Position.Y, "Yentity3");
            Assert.AreEqual(1.357217, toolpath[3].Position.Z, "Zentity3");
            Assert.AreEqual(10, toolpath[3].Feedrate.Value, "Fentity3");
            Assert.IsTrue(toolpath[3].JetOn, "Jentity3");
            Assert.AreEqual(BlockType.Linear, toolpath[3].Type, "type 3");
        }
Пример #4
0
        internal NcFileParser()
        {
            path       = new ToolPath5Axis();
            splitters  = new string[] { " " };
            pathGCodes = new string[] { "G0", "G00", "G1", "G01", "G2", "G02", "G3", "G03", "G4", "G04" };
            mCodes     = new string[] { "M61", "M62", "M63", "M64", "M65", "M66" };
            pathStart  = new string[] { "START", "M61 " };
            pathEnd    = new string[] { "END", "M62" };
            invFCode   = "G93";
            //_mcodeDictionary = new MCodeDictionary();
            //mCodes = machineMCodes;
            n = "N";

            g = "G";
            x = "X";
            y = "Y";
            z = "Z";
            i = "I";
            j = "J";
            k = "K";
            a = "A";
            b = "B";
            c = "C";
            m = "M";
            f = "F";
        }
        public void CNCFileParser_filenameIsEmpty_toolpathIsNotZerolength()
        {
            string inputFile = "";

            ToolpathLib.ToolPath5Axis toolpath = ToolpathLib.CNCFileParser.CreatePath(inputFile);
            int count = toolpath.Count;

            Assert.AreEqual(0, toolpath.Count);
        }
        public void CNCFileParser_fileIsGood_toolpathIsNotZerolength()
        {
            string inputFile = "2-CELL-TEST.2.nc";

            ToolpathLib.ToolPath5Axis toolpath = ToolpathLib.CNCFileParser.CreatePath(inputFile);
            int count = toolpath.Count;

            Assert.AreNotEqual(0, toolpath.Count);
        }
        public void CNCFileParser_ParseNCIFile_toolpathIsNotZerolength()
        {
            string inputFile = "SPLINE-CHANNEL-CONTOURPATH.NCI";

            ToolpathLib.ToolPath5Axis toolpath = ToolpathLib.CNCFileParser.CreatePath(inputFile);
            int count = toolpath.Count;

            Assert.IsFalse(count == 0);
        }
        public void CNCFileParser_ParseNCFile_toolpathhasCorrectValues()
        {
            string inputFile = "SPLINE-CHANNEL-CONTOURPATH.NC";

            ToolpathLib.ToolPath5Axis toolpath = ToolpathLib.CNCFileParser.CreatePath(inputFile);
            int    last = toolpath.Count - 1;
            string position;

            Assert.AreEqual(0, toolpath[0].Position.X, "x entity0");
            Assert.AreEqual(0.0, toolpath[0].Position.Y, "y entity0");
            Assert.AreEqual(3.307, toolpath[0].Position.Z, "z entity0");
            Assert.AreEqual(0, toolpath[0].Feedrate.Value, "f entity0");
            Assert.IsFalse(toolpath[0].JetOn, "j entity0");

            position = "1";
            Assert.AreEqual(-3.8765, toolpath[1].Position.X, "x entity1");
            Assert.AreEqual(0.05, toolpath[1].Position.Y, "y entity1");
            Assert.AreEqual(3.307, toolpath[1].Position.Z, "z entity1");
            Assert.AreEqual(0, toolpath[1].Feedrate.Value, "f entity1");
            Assert.IsFalse(toolpath[1].JetOn, "entity1");
            Assert.AreEqual(BlockType.Rapid, toolpath[1].Type, "type 1");

            position = "2";
            Assert.AreEqual(-3.8765, toolpath[2].Position.X, "X entity 2");
            Assert.AreEqual(0.05, toolpath[2].Position.Y, "Y entity 2");
            Assert.AreEqual(1.407, toolpath[2].Position.Z, "Z entity2");
            Assert.AreEqual(0, toolpath[2].Feedrate.Value, "F entity2");
            Assert.IsFalse(toolpath[2].JetOn, "J entity3");
            Assert.AreEqual(BlockType.Rapid, toolpath[2].Type, "type 2");

            position = "6";
            Assert.AreEqual(-3.5658, toolpath[6].Position.X, "X entity" + position);
            Assert.AreEqual(0.05, toolpath[6].Position.Y, "Y entity" + position);
            Assert.AreEqual(1.3572, toolpath[6].Position.Z, "Z entity" + position);
            Assert.AreEqual(10, toolpath[6].Feedrate.Value, "F entity" + position);
            Assert.IsTrue(toolpath[6].JetOn, "J entity" + position);
            Assert.AreEqual(BlockType.Linear, toolpath[6].Type, "type " + position);

            position = "last-1";

            Assert.AreEqual(4.6218, toolpath[last - 1].Position.X, "X entity" + position);
            Assert.AreEqual(0.05, toolpath[last - 1].Position.Y, "Y entity" + position);
            Assert.AreEqual(1.0623, toolpath[last - 1].Position.Z, "Z entity" + position);
            Assert.AreEqual(10, toolpath[last - 1].Feedrate.Value, "F entity " + position);
            Assert.IsFalse(toolpath[last - 1].JetOn, "J entity" + position);
            Assert.AreEqual(BlockType.Delay, toolpath[last - 1].Type, "type " + position);

            position = "last";
            Assert.AreEqual(4.6218, toolpath[last].Position.X, "X entity" + position);
            Assert.AreEqual(0.05, toolpath[last].Position.Y, "Y entity" + position);
            Assert.AreEqual(3.307, toolpath[last].Position.Z, "Z entity" + position);
            Assert.AreEqual(0, toolpath[last].Feedrate.Value, "F entity " + position);
            Assert.IsFalse(toolpath[last].JetOn, "J entity" + position);
            Assert.AreEqual(BlockType.Rapid, toolpath[last].Type, "type " + position);
        }
        public ModelPath Build(ToolPath5Axis inputPath, double increment)
        {
            averageSpacing = 0;
            pointCount     = 0;
            if (inputPath.Count > 0 && increment > 0)
            {
                return(parsePath(inputPath, increment));
            }

            return(new ModelPath());
        }
Пример #10
0
        public List <string> Build(ToolPath5Axis path, bool invertFeedrates, List <string> header)
        {
            invertF = invertFeedrates;
            var file = new List <string>();

            file.AddRange(header);
            foreach (PathEntity5Axis pe in path)
            {
                file.Add(buildLine(pe));
            }
            return(file);
        }
Пример #11
0
        public BoundingBox getBoundingBox(ToolPath5Axis inputPath)
        {
            var pointList = new List <Vector3>();

            foreach (PathEntity5Axis ent in inputPath)
            {
                pointList.Add(new Vector3(ent.Position.X, ent.Position.Y, ent.Position.Z));
            }

            BoundingBox ext = BoundingBoxBuilder.FromPtArray(pointList.ToArray());

            return(ext);
        }
Пример #12
0
        public XSecPathList Build(ToolPath5Axis inputPath, double increment, Plane xsectionPlane)
        {
            try
            {
                _xSectPlane = xsectionPlane;
                if (inputPath.Count == 0)
                {
                    throw new InvalidOperationException("inputpath length must be > 0");
                }
                if (increment <= 0)
                {
                    throw new InvalidOperationException("path increment must be > 0");
                }

                return(parsePath(inputPath, increment));
            }
            catch (Exception)
            {
                throw;
            }
        }
        public ModelPath Build(ToolPath5Axis inputPath, double increment)
        {
            try
            {
                isFiveAxis = false;
                if (inputPath.Count == 0)
                {
                    throw new InvalidOperationException("inputpath length must be > 0");
                }
                if (increment <= 0)
                {
                    throw new InvalidOperationException("path increment must be > 0");
                }

                return(parsePath(inputPath, increment));
            }
            catch (Exception)
            {
                throw;
            }
        }
        ModelPath parsePath(ToolPath5Axis inputPath, double timeIncrement)
        {
            ModelPath mp = new ModelPath(getBoundingBox(inputPath), getJetOnBoundingBox(inputPath));

            double cumulativeTime = inputPath[inputPath.Count - 1].CumulativeTime;

            int    totalTimeInc = (int)Math.Round(cumulativeTime / timeIncrement);
            double currentTime  = 0;
            int    j            = 1;

            while (currentTime <= cumulativeTime)
            {
                while (currentTime >= inputPath[j - 1].CumulativeTime && currentTime < inputPath[j].CumulativeTime)
                {
                    mp.Add(interpolate(inputPath[j - 1], inputPath[j], currentTime, timeIncrement));
                    currentTime += timeIncrement;
                }
                j++;
            }
            mp.IsFiveAxis = isFiveAxis;
            return(mp);
        }
Пример #15
0
        private XSecPathList parsePath(ToolPath5Axis inputPath, double increment)
        {
            var mp = new XSecPathList();
            int j  = 0;

            for (int i = 1; i < inputPath.Count; i++)
            {
                if (inputPath[i].JetOn)
                {
                    if (inputPath[i - 1].Feedrate != inputPath[i].Feedrate)
                    {
                        var xpe = new XSectionPathEntity()
                        {
                            Feedrate      = inputPath[i - 1].Feedrate.Value,
                            CrossLoc      = inputPath[i - 1].PositionAsVector3.Y,
                            PassExecOrder = j++
                        };
                        mp.Add(xpe);
                    }
                }
            }
            return(mp);
        }
Пример #16
0
 internal NciFileParser()
 {
     toolpath = new ToolPath5Axis();
 }