Example #1
0
 /// <summary>
 /// Copy another SimpleDatum into this one.
 /// </summary>
 /// <param name="d">Specifies the SimpleDatum to copy.</param>
 /// <param name="bCopyData">Specifies whether or not to copy the data.</param>
 public void Copy(SimpleDatum d, bool bCopyData)
 {
     m_bIsRealData        = d.m_bIsRealData;
     m_nLabel             = d.m_nLabel;
     m_nOriginalLabel     = d.m_nOriginalLabel;
     m_nChannels          = d.m_nChannels;
     m_nHeight            = d.m_nHeight;
     m_nWidth             = d.m_nWidth;
     m_rgRealData         = Utility.Clone <double>(d.m_rgRealData);
     m_rgByteData         = Utility.Clone <byte>(d.m_rgByteData);
     m_dt                 = d.m_dt;
     m_nOriginalBoost     = d.m_nOriginalBoost;
     m_nBoost             = d.m_nBoost;
     m_bAutoLabeled       = d.m_bAutoLabeled;
     m_nImageID           = d.m_nImageID;
     m_nVirtualID         = d.m_nVirtualID;
     m_nGroupID           = d.m_nGroupID;
     m_nIndex             = d.m_nIndex;
     m_strDesc            = d.m_strDesc;
     m_rgDataCriteria     = d.m_rgDataCriteria;
     m_dataCriteriaFormat = d.m_dataCriteriaFormat;
     m_rgDebugData        = d.m_rgDebugData;
     m_debugDataFormat    = d.m_debugDataFormat;
     m_nSourceID          = d.m_nSourceID;
 }
Example #2
0
        /// <summary>
        /// Unpack the byte array into a list of <i>double</i> values.
        /// </summary>
        /// <param name="rg">Specifies the byte array containing the list.</param>
        /// <param name="fmtExpected">Specifies the expected format.</param>
        /// <returns>The list of <i>double</i> values is returned.</returns>
        public static List <double> UnPackDoubleList(byte[] rg, DATA_FORMAT fmtExpected)
        {
            using (MemoryStream ms = new MemoryStream(rg))
                using (BinaryReader br = new BinaryReader(ms))
                {
                    DATA_FORMAT fmt1 = (DATA_FORMAT)br.ReadInt32();

                    if (fmtExpected != DATA_FORMAT.LIST_DOUBLE)
                    {
                        throw new Exception("The format expected should be DATA_FORMAT.LIST_DOUBLE, but instead it is '" + fmtExpected.ToString() + "'.");
                    }

                    if (fmt1 != fmtExpected)
                    {
                        throw new Exception("Invalid data format, expected '" + fmtExpected.ToString() + "' but found '" + fmt1.ToString() + "'.");
                    }

                    int           nCount = br.ReadInt32();
                    List <double> rgData = new List <double>();

                    for (int i = 0; i < nCount; i++)
                    {
                        rgData.Add(br.ReadDouble());
                    }

                    return(rgData);
                }
        }
Example #3
0
 public XCode(XInterface _Interface, DATA_FORMAT Format)
 {
     m_Code      = COM_CODE.INTERFACE;
     m_Calc      = null;
     m_Format    = Format;
     m_Interface = _Interface;
 }
Example #4
0
 public XCode(XCalc _Calc, DATA_FORMAT Format)
 {
     m_Code      = COM_CODE.CALC;
     m_Calc      = _Calc;
     m_Format    = Format;
     m_Interface = null;
 }
Example #5
0
        /// <summary>
        /// Pack a list of <i>double</i> into a byte array.
        /// </summary>
        /// <param name="rg">Specifies the list of <i>double</i> values to pack.</param>
        /// <param name="fmt">Returns the format LIST_DOUBLE</param>
        /// <returns>The byte array is returned.</returns>
        public static byte[] Pack(List <double> rg, out DATA_FORMAT fmt)
        {
            fmt = DATA_FORMAT.LIST_DOUBLE;

            using (MemoryStream ms = new MemoryStream())
                using (BinaryWriter bw = new BinaryWriter(ms))
                {
                    bw.Write((int)fmt);
                    bw.Write(rg.Count);

                    for (int i = 0; i < rg.Count; i++)
                    {
                        bw.Write(rg[i]);
                    }

                    bw.Flush();
                    return(ms.ToArray());
                }
        }