Example #1
0
        private string ProcessDraw(DataTable dataTable, ref int dataTableIndex, out HbCurveArrArray hbCurveArrArray)
        {
            string returnValue = "";

            hbCurveArrArray = new HbCurveArrArray();
            HbCurveArray hbCurveArray = null;

            if (dataTableIndex >= dataTable.Rows.Count - 1)
            {
                return("Program error: dataTable index value exceeded range.");
            }
            DataRow dataRow       = dataTable.Rows[dataTableIndex];
            string  actionCurrent = dataRow[2].ToString();
            int     testNextIndex = dataTableIndex + 1;

            if (testNextIndex > dataTable.Rows.Count - 1)
            {
                return("End of file encountered during Curve Array.");
            }
            bool continueLoop = true;

            hbCurveArray = new HbCurveArray(); // Need to make new array at the start
            List <HbXYZ> hbXyzList = null;

            while (continueLoop)
            {
                dataRow       = dataTable.Rows[dataTableIndex];
                actionCurrent = dataRow[2].ToString();
                string objectCurrent = dataRow[3].ToString();
                switch (actionCurrent)
                {
                case "Use":
                    returnValue = ProcessUse(dataTable, ref dataTableIndex, out hbXyzList);
                    if (returnValue != "")
                    {
                        return(returnValue);
                    }
                    testNextIndex = dataTableIndex + 1;
                    if (testNextIndex > dataTable.Rows.Count - 1)
                    {
                        return("End of file encountered during Curve Array.");
                    }
                    break;

                case "Draw":
                    // objectCurrent is not "CurveArray" first time since we are past that line when we entered the Draw state.
                    if (objectCurrent == "CurveArray")     // Starting new loop
                    {
                        hbCurveArrArray.Add(hbCurveArray); // Capture the last array
                        hbCurveArray = new HbCurveArray(); // Start new array
                    }
                    else                                   //Valid objectCurrent: "Line", "Arc", "NurbSpline", "Ellipse", "HermiteSpline"
                    {
                        if (hbXyzList == null)
                        {
                            hbXyzList = new GetHbXyzRow(dataRow).HbPoints;
                        }
                        HbCurve hbCurve;
                        returnValue = ProcessHbCurve(objectCurrent, dataRow, hbXyzList, out hbCurve);
                        if (returnValue != "")
                        {
                            return(returnValue);
                        }
                        hbCurveArray.HbCurves.Add(hbCurve);
                        hbXyzList = null;     // So that the test above will work with the next item
                    }
                    break;

                default:
                    return("Action '" + actionCurrent + "' encountered during Curve Array.");
                }
                testNextIndex = dataTableIndex + 1;
                if (testNextIndex > dataTable.Rows.Count - 1)
                {
                    return("End of file encountered during Curve Array.");
                }
                dataRow = dataTable.Rows[testNextIndex];
                if (dataRow[2].ToString() == "Add")
                {
                    continueLoop = false;              // Next row will be the add statement so break loop
                    hbCurveArrArray.Add(hbCurveArray); // Capture the last one
                }
                else
                {
                    dataTableIndex++;
                }
            } // Loop
            return("");
        }
Example #2
0
 public void Add(HbCurveArray hbCurveArray)
 {
     HbCurveArrays.Add(hbCurveArray);
 }