Пример #1
0
        /// <summary>
        ///  Get all the entities in the current model. If `dim' is >= 0, return only the
        ///  entities of the specified dimension (e.g. points if `dim' == 0). The
        ///  entities are returned as a vector of (dim, tag) integer pairs.
        /// </summary>
        public int[][] GetEntities(int dim = -1)
        {
            IntPtr dimTagsPtr = IntPtr.Zero;
            uint   dimTags_n  = 0;

            GMshNativeMethods.gmshModelGetEntities(ref dimTagsPtr, ref dimTags_n, dim, ref ierr);
            if (ierr != 0)
            {
                throw new GMshException(ierr);
            }
            int[] dimlist = new int[dimTags_n];
            Marshal.Copy(dimTagsPtr, dimlist, 0, dimTags_n.Toint());
            dimTagsPtr.GmshFree();
            int[][] api_dimtags = new int[2][];
            api_dimtags[0] = new int[dimTags_n / 2];
            api_dimtags[1] = new int[dimTags_n / 2];
            for (int i = 0; i < dimTags_n / 2; i++)
            {
                var index = i * 2;
                api_dimtags[0][i] = dimlist[index];
                api_dimtags[1][i] = dimlist[index + 1];
            }
            return(api_dimtags);
        }