Пример #1
0
        private void getData()
        {
            using (TextFieldParser parser = new TextFieldParser(@"C:\Users\micha\Desktop\constants.csv"))
            {
                parser.TextFieldType = FieldType.Delimited;
                parser.SetDelimiters(",");
                int rowNum = 0;
                while (!parser.EndOfData)
                {
                    //Title row (glass thickness, string glass Type)
                    string[] fields = parser.ReadFields();
                    //get the glass thinkness
                    int w;
                    int.TryParse(fields[0], out w);
                    GlassPanelModel gp = new GlassPanelModel(fields[1], w);

                    //4 rows of constants
                    for (int i = 0; i < 4; i++)
                    {
                        string[] Kfields = parser.ReadFields();
                        gp.setConstantsRow(i, Kfields);
                    }

                    //Add it to the appropriate list
                    if (gp.glassType == "Annealed")
                    {
                        Annealed.Add(gp);
                    }
                    else if (gp.glassType == "Laminated")
                    {
                        Laminated.Add(gp);
                    }
                    else if (gp.glassType == "Heated")
                    {
                        Heated.Add(gp);
                    }
                    else if (gp.glassType == "Toughened")
                    {
                        Toughened.Add(gp);
                    }
                    else
                    {
                        throw new Exception("Not a type of glass");
                    }
                }
            }
        }
Пример #2
0
        private int getAspectRatioColumn(GlassPanelModel gp, int width, int height)
        {
            //Finding the AspectRatio (aspect ratio is also y-component of gpmodel)
            double[] ARs = new double[] { 1, 1.25, 1.5, 1.75, 2, 2.5, 3, 5 };

            //set shortest and longest lengths
            double longestLength;
            double shortestLength;

            if (width >= height)
            {
                longestLength = width; shortestLength = height;
            }
            else
            {
                longestLength = height; shortestLength = width;
            }

            double aspectRatio = longestLength / shortestLength;

            if (aspectRatio > 5)
            {
                throw new Exception("Aspect ratio is greater than 5");
            }
            int i = 0;

            while (i < ARs.Length)
            {
                if (aspectRatio <= ARs[i])
                {
                    //i is now the value of the ARs array
                    break;
                }
                i++;
            }
            return(i);
        }
Пример #3
0
        private bool isAllowable(int width, int height, GlassPanelModel gp, string pressureRating)
        {
            double actualPressure = pressureRatingStringToInt(pressureRating);
            int    AR             = getAspectRatioColumn(gp, width, height);

            //getConstants
            double[] constants = gp.getConstantsColumn(AR);

            double allowableSpanB = calcAllowableSpanB(constants, actualPressure);

            //Span B is the smallest dimension
            int SpanB;

            if (width <= height)
            {
                SpanB = width;
            }
            else
            {
                SpanB = height;
            }

            return(SpanB <= allowableSpanB);
        }