Beispiel #1
0
        /// <summary>
        /// Check if the data passed in are without the Tolerance
        /// </summary>
        /// <param name="data">The data to be analyzed</param>
        /// <param name="verboseLogging">Set this to tru to get verbose information</param>
        /// <returns>true if the data is bounded by the Tolerance, false otherwise</returns>
        public bool TestValues(double[] data, bool verboseLogging)
        {
            bool bPass = true;

            if (data == null)
            {
                throw new ArgumentNullException("data", "value null be set to a valid instance of double[] (null passed in)");
            }

            AddNamedData(data, "Error Histogram");

            double[] threshold = new double[data.Length];
            for (int j = 0; j < data.Length; j++)
            {
                threshold[j] = 1.0;         // double.MaxValue;
            }

            if (CurveTolerance.Entries == null || CurveTolerance.Entries.Count == 0)
            {
                // No Tolerance ( default every entry to 0 )
                for (int t = 0; t < 255; t++)
                {
                    threshold[t] = 0.0;
                }
            }
            else
            {
                for (int t = 0; t < threshold.Length; t++)
                {
                    threshold[t] = CurveTolerance.InterpolatedValue((byte)t);
                }
            }

            double sentinel = 1.0;

            for (int j = 0; j < data.Length; j++)
            {
                if (threshold[j] != sentinel && threshold[j] != 1.0)
                {
                    sentinel = threshold[j];
                }
                threshold[j] = sentinel;

                // we do not test on 0 - for UI usability
                if (j > 0 && threshold[j] < data[j])
                {
                    bPass = false;
                }
                if (verboseLogging)
                {
                    Console.WriteLine(string.Format("{0,-6} {1,-6} {2,-8} {3,-5}", bPass, j, threshold[j], data[j], (threshold[j] >= data[j] ? "Pass" : "Fail")));
                }
            }
            if (verboseLogging)
            {
                Console.WriteLine("\nDiff Test: " + (bPass == true ? "Pass\n" : "Fail\n"));
            }

            return(bPass);
        }
Beispiel #2
0
        /// <summary>
        /// Returns a deep copy of a CurveTolerance object
        /// </summary>
        /// <returns></returns>
        public object Clone()
        {
            CurveTolerance retVal = new CurveTolerance();

            retVal._currentDpiRatio = this._currentDpiRatio;
            retVal._mapping         = new Dictionary <float, SortedDictionary <byte, double> >();
            foreach (float dpiRation in this._mapping.Keys)
            {
                SortedDictionary <byte, double> thisDico = this._mapping[dpiRation];
                SortedDictionary <byte, double> newDico  = new SortedDictionary <byte, double>();
                foreach (byte x in thisDico.Keys)
                {
                    newDico.Add(x, thisDico[x]);
                }
                retVal._mapping.Add(dpiRation, newDico);
            }
            return(retVal);
        }