示例#1
0
        public cfloat3 ConvertPtToFloat3(Point3d p)
        {
            cfloat3 a = new cfloat3();

            a.x = (float)p.X;
            a.y = (float)p.Y;
            a.z = (float)p.Z;
            return(a);
        }
示例#2
0
        public Point3f ConvertFloat3ToPt(cfloat3 p)
        {
            Point3f a = new Point3f();

            a.X = p.x;
            a.Y = p.y;
            a.Z = p.z;
            return(a);
        }
示例#3
0
        public bool GenMetaBalls(ref List <Point3f> vertices, ref int num_activeVoxels)
        {
            int     sampleCount = samplePoints.Count();
            cfloat3 bP          = ConvertPtToFloat3(basePoint);
            cfloat3 vS          = ConvertPtToFloat3(voxelSize);

            cfloat3[] smaplePts = new cfloat3[sampleCount];
            for (int i = 0; i < sampleCount; i++)
            {
                smaplePts[i] = ConvertPtToFloat3(samplePoints[i]);
            }

            uint resultLength = 0;
            bool successful   = CalcMetaBalls(bP, vS, xCount, yCount, zCount, scale, isoValue, fusion, smaplePts, sampleCount, ref resultLength);

            if (successful == false)
            {
                return(successful);
            }
            else
            {
                int    size   = Marshal.SizeOf(typeof(cfloat3)) * (int)resultLength;
                IntPtr result = Marshal.AllocHGlobal(size);

                GetResult(result);
                Point3f[] pts = new Point3f[(int)resultLength];

                Parallel.For(0, (int)resultLength, i =>
                {
                    IntPtr pPointor = new IntPtr(result.ToInt64() + Marshal.SizeOf(typeof(cfloat3)) * i);
                    pts[i]          = ConvertFloat3ToPt((cfloat3)Marshal.PtrToStructure(pPointor, typeof(cfloat3)));
                });
                Marshal.FreeHGlobal(result);
                vertices = pts.ToList();
                return(successful);
            }
        }
示例#4
0
 public static extern bool CalcMetaBalls(cfloat3 bP, cfloat3 vS, int xCount, int yCount, int zCount,
                                         float s, float iso, float fusion, cfloat3[] samplePoints, int sampleCount, ref uint resultLength);