Пример #1
0
        /// <summary>
        /// 获取网格顶点
        /// </summary>
        public void GetNodes(out long[] nodeTags, out double[] coord, out double[] parametricCoord, int dim = -1, int tag = -1, bool includeBoundary = false, bool returnParametricCoord = true)
        {
            IntPtr api_nodeTagsPtr        = IntPtr.Zero;
            IntPtr api_coordPtr           = IntPtr.Zero;
            IntPtr api_parametricCoordPtr = IntPtr.Zero;

            ulong api_nodeTags_n        = 0;
            ulong api_coord_n           = 0;
            ulong api_parametricCoord_n = 0;

            GMshNativeMethods.gmshModelMeshGetNodes(ref api_nodeTagsPtr, ref api_nodeTags_n, ref api_coordPtr, ref api_coord_n, ref api_parametricCoordPtr, ref api_parametricCoord_n, dim, tag, includeBoundary.Toint(), returnParametricCoord.Toint(), ref ierr);
            if (ierr != 0)
            {
                throw new GMshException(ierr);
            }

            nodeTags        = new long[api_nodeTags_n];
            coord           = new double[api_coord_n];
            parametricCoord = new double[api_parametricCoord_n];


            if (api_nodeTags_n != 0)
            {
                Marshal.Copy(api_nodeTagsPtr, nodeTags, 0, api_nodeTags_n.Toint());
            }
            if (api_coord_n != 0)
            {
                Marshal.Copy(api_coordPtr, coord, 0, api_coord_n.Toint());
            }
            if (api_coord_n != 0)
            {
                Marshal.Copy(api_parametricCoordPtr, parametricCoord, 0, api_parametricCoord_n.Toint());
            }

            api_nodeTagsPtr.GmshFree();
            api_coordPtr.GmshFree();
            api_parametricCoordPtr.GmshFree();
        }