public SimpleVTSFileOutput(MultiChannelInput <IDataChannel> mci, string path, bool createFileSeries = false) : base(mci, path)
        {
            this.fileWriteThreshold = 0.0f;
            this.createFileSeries   = createFileSeries;

            PhysicalBoundaries boundaries = ChannelMapper.GetChannelInputBoundaries(mci);
            var filter = FilterManager.FindFilter <FFTWFilter>(mci.GetChannel(0));

            if (filter == null)
            {
                throw new Exception("SimpleVTSFileOutput supports FFTWFilter only.");
            }
            var filterSettings = filter.GetSettings();

            if (filterSettings.OutputFormat != FFTOutputFormat.Magnitude)
            {
                throw new InvalidDataException($"SimpleVTSFileOutput needs and FFT output format of 'Magnitude'. Your FFT filter has '{filterSettings.OutputFormat}'.");
            }

            this.fftSize = filterSettings.FFTSampleCount;
            zSize        = fftSize / 2;

            channelCount = mci.ChannelCount;

            header   = $"<VTKFile type=\"StructuredGrid\" version=\"1.0\" byte_order=\"LittleEndian\" header_type=\"UInt64\">{Environment.NewLine}<StructuredGrid WholeExtent=\"0 {channelCount-1} 0 0 0 {zSize-1}\">{Environment.NewLine}<Piece Extent=\"0 {channelCount - 1} 0 0 0 {zSize - 1}\">{Environment.NewLine}";
            footer   = $"</Piece>{Environment.NewLine}</StructuredGrid>{Environment.NewLine}</VTKFile>{Environment.NewLine}";
            cellData = $"<CellData>{Environment.NewLine}</CellData>{Environment.NewLine}";

            sb = new StringBuilder();
            lock (sb)
            {
                sb.AppendLine("<Points>");
                sb.AppendLine("<DataArray type=\"Float32\" Name=\"Points\" NumberOfComponents=\"3\" format=\"ascii\">");
                for (int z = 0; z < zSize; z++)
                {
                    for (int chIndex = 0; chIndex < channelCount; chIndex++)
                    {
                        PhysicalPosition pp = ChannelMapper.GetChannelPosition(mci.GetChannel(chIndex));

                        sb.AppendLine(pp.X.ToString("0.0000000000") + " " + pp.Y.ToString("0.0000000000") + " " + (pp.Z + (z * filter.FrequencyStep)).ToString("0.0000000000"));
                    }
                }
                sb.AppendLine("</DataArray>");
                sb.AppendLine("</Points>");
                points = sb.ToString();
            }
        }
Exemplo n.º 2
0
        public static PhysicalBoundaries GetChannelInputBoundaries(MultiChannelInput <IDataChannel> mci)
        {
            PhysicalBoundaries result = new PhysicalBoundaries()
            {
                MinX = Int32.MaxValue, MinY = Int32.MaxValue, MinZ = Int32.MaxValue, MaxX = Int32.MinValue, MaxY = Int32.MinValue, MaxZ = Int32.MinValue
            };

            for (int i = 0; i < mci.ChannelCount; i++)
            {
                IDataChannel     ch = mci.GetChannel(i);
                PhysicalPosition pp = ChannelMapper.GetChannelPosition(ch);

                if (pp.X < result.MinX)
                {
                    result.MinX = pp.X;
                }
                if (pp.X > result.MaxX)
                {
                    result.MaxX = pp.X;
                }
                if (pp.Y < result.MinY)
                {
                    result.MinY = pp.Y;
                }
                if (pp.Y > result.MaxY)
                {
                    result.MaxY = pp.Y;
                }
                if (pp.Z < result.MinZ)
                {
                    result.MinZ = pp.Z;
                }
                if (pp.Z > result.MaxZ)
                {
                    result.MaxZ = pp.Z;
                }
            }

            return(result);
        }