コード例 #1
0
ファイル: Hdf5Compounds.cs プロジェクト: SBahre/HDF5_PPL_LUMC
        private static long create_type(Type t)
        {
            var size       = Marshal.SizeOf(t);
            var float_size = Marshal.SizeOf(typeof(float));
            var int_size   = Marshal.SizeOf(typeof(int));
            var typeId     = H5T.create(H5T.class_t.COMPOUND, new IntPtr(size));

            var compoundInfo = Hdf5.GetCompoundInfo(t);

            foreach (var cmp in compoundInfo)
            {
                //Console.WriteLine(string.Format("{0}  {1}", cmp.name, cmp.datatype));
                H5T.insert(typeId, cmp.name, Marshal.OffsetOf(t, cmp.name), cmp.datatype);
            }
            return(typeId);
        }
コード例 #2
0
ファイル: Hdf5Compounds.cs プロジェクト: SBahre/HDF5_PPL_LUMC
        ///
        private static int calcCompoundSize(Type type, bool useIEEE, ref hid_t id)
        {
            // Create the compound datatype for the file.  Because the standard
            // types we are using for the file may have different sizes than
            // the corresponding native types
            var compoundInfo = Hdf5.GetCompoundInfo(type, useIEEE);
            var curCompound  = compoundInfo.Last();
            var compoundSize = curCompound.offset + curCompound.size;

            //Create the compound datatype for memory.
            id = H5T.create(H5T.class_t.COMPOUND, new IntPtr(compoundSize));
            foreach (var cmp in compoundInfo)
            {
                H5T.insert(id, cmp.name, new IntPtr(cmp.offset), cmp.datatype);
            }
            return(compoundSize);
        }
コード例 #3
0
        private static long CreateType(Type t)
        {
            var size       = Marshal.SizeOf(t);
            var float_size = Marshal.SizeOf(typeof(float));
            var int_size   = Marshal.SizeOf(typeof(int));
            var typeId     = H5T.create(H5T.class_t.COMPOUND, new IntPtr(size));

            var compoundInfo = Hdf5.GetCompoundInfo(t);

            foreach (var cmp in compoundInfo)
            {
                //Console.WriteLine(string.Format("{0}  {1}", cmp.name, cmp.datatype));
                // Lines below don't produce an error message but hdfview can't read compounds properly
                //var typeLong = GetDatatype(cmp.type);
                //H5T.insert(typeId, cmp.name, Marshal.OffsetOf(t, cmp.name), typeLong);
                H5T.insert(typeId, cmp.name, Marshal.OffsetOf(t, cmp.name), cmp.datatype);
            }
            return(typeId);
        }