Ejemplo n.º 1
0
        //Exports all of the curve data to the given stream with each curve having its own line
        private void ExportToStreamEachCurveSeparately(Stream str, CoordSettings coord, GridMeshSettings grid,
                                                       ExportSettings xport, int xPrecision, int yPrecision)
        {
            // list of x values in ascending order
            List <double> xUsed = AscendingXValuesList(coord, grid, xport, xPrecision);

            StreamWriter writer = new StreamWriter(str);

            foreach (NuGenPointSet pointset in curveList)
            {
                if (pointset.Export)
                {
                    if (xport.header != ExportHeader.HeaderNone)
                    {
                        writer.Write(ExportHeaderPrefix(coord, xport));
                        writer.Write(xport.GetDelimiter());
                        writer.Write(pointset.ExportCurveHeader(xport));
                        writer.Write("\n");
                    }

                    if (xport.pointsSelection == ExportPointsSelection.XYFromAllCurves)
                    {
                        writer.Write(pointset.ExportCurveAll(xport, xPrecision, yPrecision));
                    }
                    else
                    {
                        bool useInterpolation = true;

                        foreach (double itrX in xUsed)
                        {
                            writer.Write(Math.Round(itrX, xPrecision));
                            writer.Write(xport.GetDelimiter());
                            writer.Write(pointset.ExportCurvePoint(itrX, coord, useInterpolation, yPrecision));
                            writer.Write("\n");
                        }

                        if (xport.header == ExportHeader.HeaderGnuplot)
                        {
                            writer.Write("\n\n");
                        }
                    }
                }
            }

            writer.Flush();
            writer.Close();
        }
Ejemplo n.º 2
0
        // curves can be exported together in multiple columns, or one after the other in the same column
        private void ExportToStreamAllCurvesTogether(Stream str, CoordSettings coord, GridMeshSettings grid,
                                                     ExportSettings xport, int xPrecision, int yPrecision)
        {
            // list of x values in ascending order
            List <double> xUsed = AscendingXValuesList(coord, grid, xport, xPrecision);

            StreamWriter writer = new StreamWriter(str);

            if (xport.header != ExportHeader.HeaderNone)
            {
                // header
                writer.Write(ExportHeaderPrefix(coord, xport));
                foreach (NuGenPointSet pointset in curveList)
                {
                    if (pointset.Export)
                    {
                        writer.Write(xport.GetDelimiter());
                        writer.Write(pointset.ExportCurveHeader(xport));
                    }
                }
                writer.Write("\n");
            }

            // if only allowing raw data, then forgo interpolation
            bool useInterpolation = (xport.pointsSelection != ExportPointsSelection.XYFromAllCurves);

            foreach (double itrX in xUsed)
            {
                writer.Write(Math.Round(itrX, xPrecision).ToString());
                foreach (NuGenPointSet pointset in curveList)
                {
                    if (pointset.Export)
                    {
                        writer.Write(xport.GetDelimiter());
                        writer.Write(pointset.ExportCurvePoint(itrX, coord, useInterpolation, yPrecision));
                    }
                }

                writer.Write("\n");
            }

            writer.Flush();
            writer.Close();
        }
Ejemplo n.º 3
0
 // return the name of this pointset, filtering out any embedded delimiters for easier parsing
 // downstream (which would be performed by external applications)
 public string ExportCurveHeader(ExportSettings xport)
 {
     return(name.Replace(xport.GetDelimiter(), ""));
 }
Ejemplo n.º 4
0
 // return the name of this pointset, filtering out any embedded delimiters for easier parsing
 // downstream (which would be performed by external applications)
 public string ExportCurveHeader(ExportSettings xport)
 {
     return name.Replace(xport.GetDelimiter(), "");
 }