示例#1
0
        /// <summary>
        /// This method makes sure that all spectra passed in have the same step size, if not then an error is thrown.
        /// It also equalizes the lowest and highest wavelengths.
        /// </summary>
        /// <param name="spectraBank">All the spectra that must be compared and equalized.</param>
        public static void NormalizeSpectra(List <SpectralData> spectraBank)
        {
            int index;
            int stepSize;
            int lowestWavelength;
            int highestWavelength;

            // Get specra count
            //
            int spectraCount = spectraBank.Count;

            // Make sure step size is consistent. And while looping, also find lowest and highest wavelengths
            //
            stepSize          = spectraBank[0].StepSize;
            lowestWavelength  = spectraBank[0].LowestWavelength;
            highestWavelength = spectraBank[0].HighestWavelength;

            for (index = 1; index < spectraCount; index++)
            {
                if (stepSize != spectraBank[index].StepSize)
                {
                    throw new InvalidOperationException("Step sizes amongst the chosen spectra were not consistent. This error cannot be recovered from");
                }

                int candidateForLow  = spectraBank[index].LowestWavelength;
                int candidateForHigh = spectraBank[index].HighestWavelength;

                if (candidateForLow < lowestWavelength)
                {
                    lowestWavelength = candidateForLow;
                }

                if (candidateForHigh > highestWavelength)
                {
                    highestWavelength = candidateForHigh;
                }
            }

            // Normalize the lowest & highest wavelengths for all spectra
            //
            for (index = 0; index < spectraCount; index++)
            {
                SpectralData temp = spectraBank[index];

                if (temp.LowestWavelength != lowestWavelength)
                {
                    temp.StretchStartWavelength(lowestWavelength);
                }

                if (temp.HighestWavelength != highestWavelength)
                {
                    temp.StretchEndWavelength(highestWavelength);
                }
            }
        }
示例#2
0
        public void Initialize(XmlElement xmlNode)
        {
            this.Name = xmlNode.GetAttribute(XMLDataConstants.Name);
            int channelCount = Convert.ToInt16(((XmlElement)xmlNode.FirstChild).GetAttribute(XMLDataConstants.Count));

            ResponseSpectra = new SpectralData[channelCount];

            for (int i = 0; i < channelCount; i++)
            {
                ResponseSpectra[i] = new SpectralData();

                XmlElement spectrumXML = xmlNode.GetElementsByTagName(XMLDataConstants.WaveData)[i] as XmlElement;
                ResponseSpectra[i].Initialize(spectrumXML);
            }
        }
示例#3
0
        public void Initialize(XmlElement xmlNode)
        {
            this.Name = xmlNode.GetAttribute(XMLDataConstants.Name);
            int channelCount = Convert.ToInt16(((XmlElement)xmlNode.FirstChild).GetAttribute(XMLDataConstants.Count));

            ResponseSpectra = new SpectralData[channelCount];

            for (int i = 0; i < channelCount; i++)
            {
                ResponseSpectra[i] = new SpectralData();

                XmlElement spectrumXML = xmlNode.GetElementsByTagName(XMLDataConstants.WaveData)[i] as XmlElement;
                ResponseSpectra[i].Initialize(spectrumXML);
            }
        }
示例#4
0
 /// <summary>
 /// Default Constructor
 /// </summary>
 public Material()
 {
     this.ReflectanceDistribution = new SpectralData();
 }
示例#5
0
 /// <summary>
 /// Default constructor
 /// </summary>
 public LightSource()
 {
     SpectralPowerDistribution = new SpectralData();
 }
示例#6
0
 /// <summary>
 /// Default constructor
 /// </summary>
 public LightSource()
 {
     SpectralPowerDistribution = new SpectralData();
 }