Ejemplo n.º 1
0
        /// <summary>
        /// Create an `H5Space` with exactly 1 point selected by `index`.
        /// </summary>
        /// <remarks>
        /// The number of indices must match the rank of the dataset.
        /// </remarks>
        protected H5Space SelectPoint(params long[] index)
        {
            var space = GetSpace();

            if (index.Length != space.Rank)
            {
                throw new ArgumentException("dimension mismatch");
            }

            for (int i = 0; i < space.Rank; i++)
            {
                if (index[i] < 0 || index[i] >= space.Dims[i])
                {
                    throw new IndexOutOfRangeException("index was outside the bounds of the dataset");
                }
            }

            var coord = new ulong[space.Rank];

            for (int i = 0; i < coord.Length; i++)
            {
                coord[i] = (ulong)index[i];
            }

            H5S.select_elements(space.ID, H5S.seloper_t.SET, (IntPtr)1L, coord);

            return(space);
        }
Ejemplo n.º 2
0
        public void H5Sget_select_elem_npointsTest1()
        {
            hsize_t[] dims  = { 1, 2, 3 };
            hid_t     space = H5S.create_simple(dims.Length, dims, dims);

            Assert.IsTrue(space > 0);
            hsize_t[] sel = { 0, 1, 2 };
            Assert.IsTrue(
                H5S.select_elements(space, H5S.seloper_t.SET, new IntPtr(1),
                                    sel) >= 0);
            Assert.IsTrue(H5S.get_select_elem_npoints(space) == 1);
            Assert.IsTrue(H5S.close(space) >= 0);
        }
        public void H5Sget_select_elem_pointlistTest1()
        {
            hsize_t[] dims  = { 1, 2, 3 };
            hid_t     space = H5S.create_simple(dims.Length, dims, dims);

            Assert.IsTrue(space > 0);
            hsize_t[] sel = { 0, 1, 2, 0, 2, 2 };
            Assert.IsTrue(
                H5S.select_elements(space, H5S.seloper_t.SET, new IntPtr(2),
                                    sel) >= 0);
            hsize_t[] buf = new hsize_t[sel.Length];
            Assert.IsTrue(H5S.get_select_elem_pointlist(space, 0, 2, buf) >= 0);

            for (int i = 0; i < buf.Length; ++i)
            {
                Assert.IsTrue(sel[i] == buf[i]);
            }

            Assert.IsTrue(H5S.close(space) >= 0);
        }
Ejemplo n.º 4
0
        public static unsafe void AddRegionReference(long fileId, ContainerType container)
        {
            long res;

            TestUtils.AddSmall(fileId, ContainerType.Dataset);

            var length = 1UL;
            var data   = new ulong[length];

            fixed(ulong *ptr = data)
            {
                var referenceGroupId = H5G.open(fileId, "small");
                var spaceId          = H5S.create_simple(1, new ulong[] { length }, null);
                var coordinates      = new ulong[] { 2, 4, 6, 8 };

                res = H5S.select_elements(spaceId, H5S.seloper_t.SET, new IntPtr(4), coordinates);
                res = H5R.create(new IntPtr(ptr), referenceGroupId, "small", H5R.type_t.DATASET_REGION, spaceId);

                TestUtils.Add(container, fileId, "reference", "region_reference", H5T.STD_REF_DSETREG, new IntPtr(ptr).ToPointer(), length);

                res = H5S.close(spaceId);
                res = H5G.close(referenceGroupId);
            }
        }
Ejemplo n.º 5
0
 public void H5Sselect_elementsTest2()
 {
     Assert.IsFalse(
         H5S.select_elements(Utilities.RandomInvalidHandle(),
                             H5S.seloper_t.SET, IntPtr.Zero, null) >= 0);
 }