コード例 #1
0
 private void ReadColumnsLabelsBlock(BinaryReader reader, ref AdditionalRayDataColumnLabelsBlock columnLabelsBlock)
 {
     columnLabelsBlock.ColumnNames = new List <string>();
     for (int i = 0; i < FileHeader.NumberOfAdditionalRayDataItemsPerRay; i++)
     {
         columnLabelsBlock.ColumnNames.Add(new string(reader.ReadChars(512)));
     }
 }
コード例 #2
0
        public static string[] GetListofRayDataFieldsPresent(KnownDataFlagBlock dataFlagBlock, FileHeaderBlock fileHeaderBlock, AdditionalRayDataColumnLabelsBlock additionalRayDataColumn = null)
        {
            Type type = typeof(KnownDataFlagBlock);

            string[] rayitems = new string[FindNumberOfRayDataFields(dataFlagBlock, fileHeaderBlock)];
            var      position = 0;

            foreach (FieldInfo fi in type.GetFields(BindingFlags.Instance | BindingFlags.Public))
            {
                if (fi.Name == "PositionFlag" && (int)fi.GetValue(dataFlagBlock) == 1)
                {
                    rayitems[0] = "X Position";
                    rayitems[1] = "Y Position";
                    rayitems[2] = "Z Position";
                    position   += 3;
                }
                if (fi.Name == "PositionFlag" && (int)fi.GetValue(dataFlagBlock) == 1)
                {
                    rayitems[3] = "X Direction Cosine";
                    rayitems[4] = "Y Direction Cosine";
                    rayitems[5] = "Z Direction Cosine";
                    position   += 3;
                }
                if (fi.Name == "RadiantFlux_StokesS0Flag" && (int)fi.GetValue(dataFlagBlock) == 1)
                {
                    rayitems[position] = "Radiant Flux/Stokes S0";
                    position          += 1;
                }

                if (fi.Name == "WavelengthFlag" && (int)fi.GetValue(dataFlagBlock) == 1)
                {
                    rayitems[position] = "Wavelength";
                    position          += 1;
                }

                if (fi.Name == "LuminousFlux_TristimulusYFlag" && (int)fi.GetValue(dataFlagBlock) == 1)
                {
                    rayitems[position] = "LuminousFlux / Tristimulus Y";
                    position          += 1;
                }

                if (fi.Name == "StokesFlag" && (int)fi.GetValue(dataFlagBlock) == 1)
                {
                    rayitems[position]     = "Stokes S1";
                    rayitems[position + 1] = "Stokes S2";
                    rayitems[position + 2] = "Stokes S3";
                    position += 3;
                }

                if (fi.Name == "TristimulusFlag" && (int)fi.GetValue(dataFlagBlock) == 1)
                {
                    rayitems[position]     = "X Tristimulus";
                    rayitems[position + 1] = "Y Tristimulus";
                    position += 2;
                }

                if (fi.Name == "SpectrumIndexFlag" && (int)fi.GetValue(dataFlagBlock) == 1)
                {
                    rayitems[position] = "Spectrum Index";
                    position          += 1;
                }

                if (fileHeaderBlock.NumberOfAdditionalRayDataItemsPerRay > 0)
                {
                    for (int i = 0; i < fileHeaderBlock.NumberOfAdditionalRayDataItemsPerRay; i++)
                    {
                        rayitems[position] = additionalRayDataColumn.ColumnNames[i];
                    }
                }
            }
            return(rayitems);
        }
コード例 #3
0
        public IESTM25File(string fileName, ulong numrays)
        {
            using (BinaryReader reader = new BinaryReader(File.Open(fileName, FileMode.Open)))
            {
                FileHeaderBlock fileHeader = new FileHeaderBlock();
                ReadHeaderBlock(reader, ref fileHeader);
                if (!fileHeader.CheckHeaderBlockisValid())
                {
                    throw new InvalidTM25Exception("Header Block Not Correct Size", "");
                }
                FileHeader = fileHeader;

                KnownDataFlagBlock knownDataFlag = new KnownDataFlagBlock();
                ReadDataFlagBlock(reader, ref knownDataFlag);
                if (!knownDataFlag.CheckKnownDataFlagBlockisValid())
                {
                    throw new InvalidTM25Exception("Data Flag Block Not Correct Size", "");
                }
                DataFlags = knownDataFlag;

                DescriptionHeaderBlock descriptionHeader = new DescriptionHeaderBlock();
                ReadDescriptionHeaderBlock(reader, ref descriptionHeader);
                if (!descriptionHeader.CheckDescriptionBlockisValid())
                {
                    throw new InvalidTM25Exception("Description Header Block is Not Correct Size", "");
                }
                DescriptionHeader = descriptionHeader;

                if (FileHeader.NumberOfSpectralTables > 0)
                {
                    SpectralTableBlock spectralTables = new SpectralTableBlock();
                    spectralTables.SpectralTables = new List <SpectralTable>();
                    ReadSpectralTableBlock(reader, ref spectralTables);
                    if (!spectralTables.CheckSpectralTableisValid())
                    {
                        throw new InvalidTM25Exception("Spectral Table Block is Not Correct Size", "");
                    }
                    SpectralTables = spectralTables;
                }

                if (FileHeader.NumberOfAdditionalRayDataItemsPerRay > 0)
                {
                    AdditionalRayDataColumnLabelsBlock columnLabelsBlock = new AdditionalRayDataColumnLabelsBlock();
                    ReadColumnsLabelsBlock(reader, ref columnLabelsBlock);
                    if (!columnLabelsBlock.CheckAdditionalRayDataColumnisValid())
                    {
                        throw new InvalidTM25Exception("Additional Ray Data Columns Block is incorrect");
                    }
                    AdditionalRayDataColumnLabels = columnLabelsBlock;
                }

                if (FileHeader.SizeOfAdditionalTextBlock > 0)
                {
                    AdditionalTextBlock additionalTextBlock = new AdditionalTextBlock();
                    ReadAdditionalTextBlock(reader, ref additionalTextBlock);
                    AdditionalText = additionalTextBlock;
                }

                RayDataLinesBlock rayDataLines = new RayDataLinesBlock();
                rayDataLines.Rays = new float[FileHeader.NumberOfRays][];
                ReadPartialRayDataBlock(reader, ref rayDataLines, numrays);
                rayDataLines.RayDataMembers = TM25HelperFunctions.GetListofRayDataFieldsPresent(DataFlags, FileHeader, AdditionalRayDataColumnLabels);
                RayData = rayDataLines;
            }
        }