|
Programming Reference for VirtualLab Fusion
2026.1
|
This class provides methods for the import and export of fields to bitmaps, text files, or bitmap animations and access to the Microsoft Windows file system. More...
Static Public Member Functions | |
| static Bitmap | CalculateBitmapFromChromaticFieldsSet2D (ChromaticFieldsSet cfs, double brightnessFactor, out bool noVisibleWavelength, bool interpolated=true, Size? numberOfPixels=null, PhysicalValueRange? xRange=null, PhysicalValueRange? yRange=null) |
| Static conversion method for creating a bitmap from a 2D Chromatic Fields Set. | |
| static Bitmap | CalculateBitmapFromDataArray2D (DataArray2D dataArray, int subsetIndex, FieldQuantity fieldQuantity, bool interpolated=true, Size? numberOfPixels=null, PhysicalValueRange? xRange=null, PhysicalValueRange? yRange=null, double minValue=double.NaN, double maxValue=double.NaN, ColorLookUpTableForDataView2D? colorTable=null, Color? colorForUndefined=null, double relativeThresholdForPhaseArtifacts=0) |
| Static public conversion method for creating a bitmap from a 2D Data Array. | |
| static IDocument | ImportBitmap (string fileName) |
| Import of a bitmap file. The document type will be determined automatically: An RGB image will be imported as HarmonicFieldsSet. A gray-scale or indexed image will be imported as DataArray. | |
| static ComplexAmplitude | ImportGrayScaleBitmap (string fileName, double minimumValue=0, double maximumValue=1, FieldQuantity fieldQuantity=FieldQuantity.RealPart, PrecisionMode precision=PrecisionMode.Double, double? wavelength=null) |
| Imports the values of a grayscale bitmap (24 bit RGB or 16 bit gray scale) into a ComplexAmplitude. The sampling distance is calculated from the dpi values of the bitmap. | |
| static ? ChromaticFieldsSet | ImportTextFileIntoChromaticFieldsSet (string fileName, double wavelength, ChromaticFieldsSetType type=ChromaticFieldsSetType.Unspecified, double samplingDistanceX=1, double samplingDistanceY=1, string commentIndicator="#", string columnSeparator=" ", string decimalSeparator=".", string groupSeparator="", int firstRow=-1, int lastRow=-1, int numberOfCharactersToSkip=0, bool decreasingXCoordinates=false, bool decreasingYCoordinates=false) |
| Imports a text file into a ChromaticFieldsSet object. | |
| static ? ChromaticFieldsSet_1D | ImportTextFileIntoChromaticFieldsSet1D (string fileName, List< double > wavelengths, ChromaticFieldsSetType type=ChromaticFieldsSetType.Unspecified, bool coordinatesAreCodedInData=false, double samplingDistance=1, string commentIndicator="#", string columnSeparator=" ", string decimalSeparator=".", string groupSeparator="", int firstRow=-1, int lastRow=-1, int numberOfCharactersToSkip=0, bool expectDataInColumns=true, bool decreasingCoordinates=false) |
| Imports a text file into a ChromaticFieldsSet_1D object. | |
| static ? ComplexField | ImportTextFileIntoComplexField (string fileName, bool expectComplexValues, int firstRow, int lastRow, int numberOfCharactersToSkip, string commentIndicator, string columnSeparator, string decimalSeparator, string groupSeparator, out List<(bool is1D, bool? isGridless, bool? isEquidistant, bool? dataInColumns, int noOfSubsets)> possibleCombinations) |
| Imports a text file into a ComplexField object. | |
| static ? DataArrayBase | ImportTextFileIntoDataArray (string fileName, bool expectComplexValues=false, bool coordinatesAreCodedInData=false, double samplingDistanceX=1, double samplingDistanceY=1, string commentIndicator="#", string columnSeparator=" ", string decimalSeparator=".", string groupSeparator="", int firstRow=-1, int lastRow=-1, int numberOfCharactersToSkip=0, bool prefer2Dover1D=true, bool preferGriddedOverGridless=true, bool expect1DOrGridlessDataInColumns=true, bool decreasingXCoordinates=false, bool decreasingYCoordinates=false, PhysicalMeaningType typeOfDA=PhysicalMeaningType.None) |
| Imports a text file into a DataArray object. | |
| static ? ComplexAmplitude | ImportTextFileIntoHarmonicField (string fileName, double wavelength, bool expectComplexValues=false, string commentIndicator="#", string columnSeparator=" ", string decimalSeparator=".", string groupSeparator="", int firstRow=-1, int lastRow=-1, int numberOfCharactersToSkip=0) |
| Imports a text file into a HarmonicField object. | |
| static ComplexAmplitude | LoadField (string fileName) |
| Loads a field from a file. | |
| static HarmonicFieldsSet | LoadFieldsSet (string fileName) |
| Loads a fields set from a file. | |
| static int | NumberOfLines (string fileName) |
| Returns the number of lines in the text file specified by fileName. | |
| static void | ProcessOpticalSetup (string fileNameOpticalSetup, string outputFolder, string fileNameParameters="", PropagationEngine? simulationEngine=null, int? analyzerIndex=null, bool useSubfolder=false) |
| Loads and simulates the given Optical Setup file. | |
| static string | ReadLine (string fileName, int lineNumber) |
| Returns the nth line of the text file specified by fileName, where \(n\) equals the lineNumber. The first line of the file is line number 1. If the file does not exist or the specified line number is beyond the end of the file, the program using this method will be stopped unless the thrown exception is handled outside of this method. | |
| static void | SaveDocument (IDocument document, string fileName) |
| Saves a document (e. g. a ComplexAmplitude or a HarmonicFieldsSet object) to the hard disc. | |
| static void | WriteLineToLogFile (string fileName, string message) |
| Writes a string as a separate line to the end of the specified log file. | |
| static void | WriteToLogFile (string fileName, string message) |
| Writes a string to the end of the specified log file. In contrast to the WriteLineToLogFile method, this method does not introduce a line break. | |
This class provides methods for the import and export of fields to bitmaps, text files, or bitmap animations and access to the Microsoft Windows file system.
|
static |
Static conversion method for creating a bitmap from a 2D Chromatic Fields Set.
| cfs | Chromatic fields set to create the bitmap from |
| brightnessFactor | Factor to increase or decrease the brightness in the bitmap to be calculated. Too high brightness can lead to oversaturation. |
| noVisibleWavelength | Out parameter that indicates whether none of the wavelengths is in the range of visible wavelengths. |
| interpolated | If this optional parameter is set to false, you see the original sampling points in the bitmap. Else an interpolation between neighbored sampling points is done. |
| numberOfPixels | Number of pixels in the resulting bitmap. If this optional parameter is not specified, one pixel per sampling point is created. |
| xRange | Optional x-coordinate range of the Chromatic Fields Set to be displayed in the bitmap. Can be used to show only a part of the Chromatic Fields Set. |
| yRange | Optional y-coordinate range of the Chromatic Fields Set to be displayed in the bitmap. Can be used to show only a part of the Chromatic Fields Set. |
|
static |
Static public conversion method for creating a bitmap from a 2D Data Array.
| dataArray | Data Array to create the bitmap from |
| subsetIndex | The index of that data subset of the Data Array to be converted to the bitmap. |
| fieldQuantity | The field quantity to be converted to the bitmap. |
| interpolated | If this optional parameter is set to false, you see the original sampling points in the bitmap. Else an interpolation between neighbored sampling points is done, using the interpolation methods (X and Y) of the data array. |
| numberOfPixels | Number of pixels in the resulting bitmap. If this optional parameter is not specified, one pixel per sampling point is created. |
| xRange | Optional x-coordinate range of the Data Array to be displayed in the bitmap. Can be used to show only a part of the Chromatic Fields Set. |
| yRange | Optional y-coordinate range of the Data Array to be displayed in the bitmap. Can be used to show only a part of the Chromatic Fields Set. |
| minValue | Optional minimum value to be mapped to a color. All values below will have the same color as this value. |
| maxValue | Optional maximum value to be mapped to a color. All values above will have the same color as this value. |
| colorTable | Optional color table for mapping double values to colors. By default the corresponding Global Option is used. |
| colorForUndefined | Color to be used for undefined values. By default the corresponding Global Option is used. |
| relativeThresholdForPhaseArtifacts | Threshold for suppressing phase artifacts. If set to zero or below, no suppression will be done. Applies only if parameter fieldQuantity is set to FieldQuantity.Phase. |
|
static |
Import of a bitmap file. The document type will be determined automatically: An RGB image will be imported as HarmonicFieldsSet. A gray-scale or indexed image will be imported as DataArray.
| fileName | Full path of image to be imported. |
|
static |
Imports the values of a grayscale bitmap (24 bit RGB or 16 bit gray scale) into a ComplexAmplitude. The sampling distance is calculated from the dpi values of the bitmap.
| fileName | File name of the bitmap to be imported. |
| minimumValue | Optional minimum value, i.e. the value of black pixels. 0 by default. |
| maximumValue | Optional maximum value, i.e. the value of white pixels. 1 by default. |
| fieldQuantity | Optional field quantity. If not specified, the data is imported into the real part. If the field quantity is Imaginary Part or Phase, the resulting ComplexAmplitude will be complex-valued, otherwise it will be real-valued. |
| precision | Optional precision. No longer used. |
| wavelength | Optional wavelength. If you specify this value, a Harmonic Field instead of a Jones Matrix Transmission is generated. |
|
static |
Imports a text file into a ChromaticFieldsSet object.
| fileName | The full path of the text file to be imported. |
| wavelength | The wavelength of the chromatic fields set to be created. |
| samplingDistanceX | The sampling distance to be used for the x-coordinates if the coordinates are not coded within the data. |
| samplingDistanceY | The sampling distance to be used for the y-coordinates if the coordinates are not coded within the data. |
| commentIndicator | The character to be interpreted as comment indicator, preceding lines which are to be ignored. |
| columnSeparator | Character which separates columns in the file. Please note: All 'white-space' characters are interchangeable. This means, for example, providing a blank will work with tabulator-separated columns and vice versa. |
| decimalSeparator | Character which separates the integer part from the fractional part of the numbers in the file. |
| groupSeparator | Character which 'groups' three digits respectively, so it can be called 'thousands separator' as well. This parameter may be left empty, meaning that no group separator is used in the file. |
| firstRow | The first row to read from file. If set to -1, all lines will be processed. |
| lastRow | The last row to read from file. If set to -1, all lines will be processed. |
| numberOfCharactersToSkip | If greater than zero, this number of characters will be ignored at the beginning of each line. |
| decreasingXCoordinates | Are the actual x-coordinates to be interpreted as decreasing with increasing column-index? |
| decreasingYCoordinates | Are the actual y-coordinates to be interpreted as decreasing with increasing row-index? |
| type | The type of object which is to be represented by the imported chromatic fields set. |
|
static |
Imports a text file into a ChromaticFieldsSet_1D object.
| fileName | The full path of the text file to be imported. |
| wavelengths | The wavelengths of the chromatic fields set to be created. |
| coordinatesAreCodedInData | Are the coordinates for all of the data points given in the text data (being the first column or row of values) as well? |
| samplingDistance | The sampling distance to be used if the coordinates are not coded within the data. |
| commentIndicator | The character to be interpreted as comment indicator, preceding lines which are to be ignored. |
| columnSeparator | Character which separates columns in the file. Please note: All 'white-space' characters are interchangeable. This means, for example, providing a blank will work with tabulator-separated columns and vice versa. |
| decimalSeparator | Character which separates the integer part from the fractional part of the numbers in the file. |
| groupSeparator | Character which 'groups' three digits respectively, so it can be called 'thousands separator' as well. This parameter may be left empty, meaning that no group separator is used in the file. |
| firstRow | The first row to read from file. If set to -1, all lines will be processed. |
| lastRow | The last row to read from file. If set to -1, all lines will be processed. |
| numberOfCharactersToSkip | If greater than zero, this number of characters will be ignored at the beginning of each line. |
| expectDataInColumns | Several data sets (corresponding to different wavelengths) can be in columns or in rows. Which option is preferred (column-wise = true vs. row-wise = false)? |
| decreasingCoordinates | Are the actual coordinates to be interpreted as decreasing with increasing column- (or row-) index? |
| type | The type of object which is to be represented by the imported chromatic fields set. |
|
static |
Imports a text file into a ComplexField object.
| fileName | Full path of the file to import. |
| expectComplexValues | If true, the values in the file are expected to be complex-valued. If the import is successful, the result will be complex-valued as well. |
| firstRow | The first row to read from file. If set to -1, all lines will be processed. |
| lastRow | The last row to read from file. If set to -1, all lines will be processed. |
| numberOfCharactersToSkip | If greater than zero, this number of characters will be ignored at the beginning of each line. |
| commentIndicator | The character to be interpreted as comment indicator, preceding lines which are to be ignored. |
| columnSeparator | Character which separates columns in the file. Please note: All 'white-space' characters are interchangeable. This means, for example, providing a blank will work with tabulator-separated columns and vice versa. |
| decimalSeparator | Character which separates the integer part from the fractional part of the numbers in the file. |
| groupSeparator | Character which 'groups' three digits respectively, so it can be called 'thousands separator' as well. This parameter may be left empty, meaning that no group separator is used in the file. |
| possibleCombinations | List of all possible property combinations a DataArray, constructed from the imported ComplexField, could have. |
|
static |
Imports a text file into a DataArray object.
| fileName | The full path of the text file to be imported. |
| expectComplexValues | Are the data to be interpreted as being complex-valued? |
| samplingDistanceX | If the coordinates are not coded within the data, this gives the sampling distance to be used in 1D case or the sampling distance for the x-coordinates in 2D case. |
| samplingDistanceY | If the coordinates are not coded within the data, this gives the sampling distance to be used for the y-coordinates in 2D case. |
| commentIndicator | The character to be interpreted as comment indicator, preceding lines which are to be ignored. |
| columnSeparator | Character which separates columns in the file. Please note: All 'white-space' characters are interchangeable. This means, for example, providing a blank will work with tabulator-separated columns and vice versa. |
| decimalSeparator | Character which separates the integer part from the fractional part of the numbers in the file. |
| groupSeparator | Character which 'groups' three digits respectively, so it can be called 'thousands separator' as well. This parameter may be left empty, meaning that no group separator is used in the file. |
| firstRow | The first row to read from file. If set to -1, all lines will be processed. |
| lastRow | The last row to read from file. If set to -1, all lines will be processed. |
| numberOfCharactersToSkip | If greater than zero, this number of characters will be ignored at the beginning of each line. |
| prefer2Dover1D | If the data can be interpreted as 2D or 1D, which one has to be preferred (2D = true vs. 1D = false)? |
| preferGriddedOverGridless | If the data are 2D and can be interpreted as being on a coordinate grid as well as being 'gridless', which one has to be preferred (gridded = true vs. gridless = false)? |
| coordinatesAreCodedInData | Are the coordinates for all of the data points given in the text data (being the first column and/or row of values) as well? |
| expect1DOrGridlessDataInColumns | If the data are 1D or gridless 2D where each of several data sets can be in columns as well as in rows - which option is preferred (column-wise = true vs. row-wise = false)? |
| decreasingXCoordinates | If the coordinates are not given in the file, are the actual x-coordinates to be interpreted as decreasing with increasing column- (or row-) index? |
| decreasingYCoordinates | If the coordinates are not given in the file, are the actual y-coordinates to be interpreted as decreasing with increasing row-index? |
| typeOfDA | The type of object which is to be represented by the imported data array. |
|
static |
Imports a text file into a HarmonicField object.
| fileName | Full path of the file to import. |
| wavelength | Wavelength for the new HarmonicField. |
| expectComplexValues | If true, the values in the file are expected to be complex-valued. If the import is successful, the result will be complex-valued as well. |
| firstRow | The first row to read from file. If set to -1, all lines will be processed. |
| lastRow | The last row to read from file. If set to -1, all lines will be processed. |
| numberOfCharactersToSkip | If greater than zero, this number of characters will be ignored at the beginning of each line. |
| commentIndicator | The character to be interpreted as comment indicator, preceding lines which are to be ignored. |
| columnSeparator | Character which separates columns in the file. Please note: All 'white-space' characters are interchangeable. This means, for example, providing a blank will work with tabulator-separated columns and vice versa. |
| decimalSeparator | Character which separates the integer part from the fractional part of the numbers in the file. |
| groupSeparator | Character which 'groups' three digits respectively, so it can be called 'thousands separator' as well. This parameter may be left empty, meaning that no group separator is used in the file. |
|
static |
Loads a field from a file.
| fileName | Full path of the file to load. Note that backslashes must be doubled, for example “C:\myField.ca2”. |
|
static |
Loads a fields set from a file.
| fileName | Full path of the file to load. Note that backslashes must be doubled, for example “C:\myFieldsSet.hfs” |
|
static |
Returns the number of lines in the text file specified by fileName.
| fileName | The full path of the file from which the text is to be read. Note that backslashes must be doubled, for example “C:\log.txt”. |
|
static |
Loads and simulates the given Optical Setup file.
| fileNameOpticalSetup | The complete path of the Optical Setup file. |
| outputFolder | The folder to which all results are written. Note that messages, warnings, and errors are still written to the Messages tab of the main window of VirtualLab Fusion. |
| fileNameParameters | If you specify this optional parameter, the parameters of the Optical Setup are overwritten with the parameters of that given file. The file must be in a specific XML format which can be generated by exporting an Optical Setup to batch mode files within VirtualLab Fusion. |
| simulationEngine | The simulation engine to use. If this optional parameter is not specified, the given analyzer is executed instead. |
| analyzerIndex | Index of the analyzer to be executed. If this optional parameter is not specified and also no simulation engine, then the default simulation engine as defined in the Global Options is used. |
| useSubfolder | If set to true a unique sub-folder for each simulation run is generated. |
|
static |
Returns the nth line of the text file specified by fileName, where \(n\) equals the lineNumber. The first line of the file is line number 1. If the file does not exist or the specified line number is beyond the end of the file, the program using this method will be stopped unless the thrown exception is handled outside of this method.
| fileName | The full path of the file from which the text is to be read. Note that backslashes must be doubled, for example “C:\log.txt”. |
| lineNumber | The line number to be read. |
| System.ArgumentException | Line number must be between 1 and the number of lines in the file. |
|
static |
Saves a document (e. g. a ComplexAmplitude or a HarmonicFieldsSet object) to the hard disc.
| document | The document to save. |
| fileName | The desired file name including the full path. Note that backslashes must be doubled, for example “C:\myField.ca2” |
|
static |
Writes a string as a separate line to the end of the specified log file.
| fileName | The full path of the file into which the text is to be written. Note that backslashes must be doubled, for example “C:\log.txt”. If the file does not exist, it is created. |
| message | The string to write into the log file. |
|
static |
Writes a string to the end of the specified log file. In contrast to the WriteLineToLogFile method, this method does not introduce a line break.
| fileName | The full path of the file into which the text is to be written. Note that backslashes must be doubled, for example “C:\log.txt”. If the file does not exist, it is created. |
| message | The string to write into the log file. |