/// <summary> /// Constructor prepares image source calculation to run. /// </summary> /// <param name="Source"></param> /// <param name="Receiver"></param> /// <param name="Direct"></param> /// <param name="Rm"></param> /// <param name="MaxOrder_in">The maximum order to be calculated for.</param> public ImageSourceData(Source Source, Receiver_Bank Receiver, Direct_Sound Direct, Polygon_Scene Rm, int[] Octaves, int MaxOrder_in, bool Edge_Diffraction, int SourceID_in) { IncludeEdges = Edge_Diffraction; Diffraction = Edge_Diffraction; Oct_choice = new int[Octaves[1] - Octaves[0] + 1]; for (int i = 0; i < Octaves.Length; i++) Oct_choice[i] = i + Octaves[0]; SrcNo = SourceID_in; ValidPaths = new List<Deterministic_Reflection>[Receiver.Count]; Speed_of_Sound = Rm.Sound_speed(0); MaxOrder = MaxOrder_in; Src = Source; Rec = new Hare.Geometry.Point[Receiver.Count]; SampleCT = Receiver.SampleCT; SampleRate = Receiver.SampleRate; for(int i = 0; i < Receiver.Count; i++) { Rec[i] = Receiver.H_Origin(i); } Room = Rm; Direct_Time = new double[Receiver.Count]; for (int q = 0; q < Receiver.Count; q++) { Direct_Time[q] = Direct.Min_Time(q); } }
/// <summary> /// Constructor which takes a Binary Reader at the appropriate point, from which calculated data will be extracted. /// </summary> /// <param name="BR"></param> /// <param name="Rec_CT"></param> /// <param name="Direct"></param> /// <returns></returns> public static ImageSourceData Read_Data(ref System.IO.BinaryReader BR, int Rec_CT, Direct_Sound Direct, bool Edges, int Src_ID, string version) { ImageSourceData IS = new ImageSourceData(); IS.ValidPaths = new List<Deterministic_Reflection>[Rec_CT]; IS.Direct_Time = new double[Rec_CT]; double v = double.Parse(version.Substring(0, 3)); for (int q = 0; q < Rec_CT; q++) { IS.ValidPaths[q] = new List<Deterministic_Reflection>(); //2. Write the receiver number:int BR.ReadInt32(); //3. Write number of paths:int int PathCt = BR.ReadInt32(); for (int i = 0; i < PathCt; i++) { int ReflectionType = BR.ReadInt16(); if (ReflectionType == 0) { //Speculare Reflection //4. Write the number of reflection path points Hare.Geometry.Point[] PTS = new Hare.Geometry.Point[BR.ReadInt32()]; //5. Write the reflection path:double for (int r = 0; r < PTS.Length; r++) { PTS[r] = new Hare.Geometry.Point(BR.ReadDouble(), BR.ReadDouble(), BR.ReadDouble()); } //Previously, Pachyderm performed the deterministic part in intensity only... //6a. Write the energy values double[] Energy = new double[8]; Energy[0] = BR.ReadDouble(); Energy[1] = BR.ReadDouble(); Energy[2] = BR.ReadDouble(); Energy[3] = BR.ReadDouble(); Energy[4] = BR.ReadDouble(); Energy[5] = BR.ReadDouble(); Energy[6] = BR.ReadDouble(); Energy[7] = BR.ReadDouble(); bool Special_Filter = BR.ReadBoolean(); System.Numerics.Complex[] Filter = null; if (Special_Filter) { //6aa1. Write length of filter... int Filter_Length = BR.ReadInt32(); Filter = new System.Numerics.Complex[Filter_Length]; //6aa2. Write filter... for(int j = 0; j < Filter.Length; j++) { Filter[j] = new System.Numerics.Complex(BR.ReadDouble(), BR.ReadDouble()); } //6aa3. Write octave band root mean square pressure... } double[] prms = new double[8]; for (int j = 0; j < prms.Length; j++) prms[j] = BR.ReadDouble(); //7. Write the arrival time:double double Time = BR.ReadDouble(); //8. Write the Reflection Sequence:int int[] Sequence = new int[PTS.Length - 2]; for (int r = 0; r < Sequence.Length; r++) { Sequence[r] = BR.ReadInt32(); } IS.ValidPaths[q].Add(new Specular_Path(PTS, Energy, prms, Filter, Time, Sequence, Direct.Min_Time(q), Src_ID)); } else if (ReflectionType == 1) { //TODO: Find a robust format for compound reflection paths... ///Specular Path: //BW.Write((short)1); //Write the number of samples and the pressure signal down: //Write the number of samples and the pressure signal down: //6a.2. Write the number of samples in the pressure signal.(int) //6b. Write the pressure values } } } return IS; }