예제 #1
0
파일: PointLayout.cs 프로젝트: PDAL/CAPI
        public PointLayout(IntPtr nativeLayout)
        {
            mNative = nativeLayout;

            IntPtr nativeTypes = (mNative != IntPtr.Zero) ? getDimTypeList(mNative) : IntPtr.Zero;

            if (nativeTypes != IntPtr.Zero)
            {
                mTypes = new DimTypeList(nativeTypes);
            }
        }
예제 #2
0
        public byte[] GetPackedPoint(DimTypeList dims, ulong idx)
        {
            byte[] data = null;

            if (this.Size > idx && dims != null && dims.Size > 0)
            {
                data = new byte[dims.ByteCount];
                getPackedPoint(mNative, dims.Native, idx, data);
            }

            return(data);
        }
예제 #3
0
        public BpcData GetBakedPointCloud()
        {
            BpcData     pc;
            ulong       size;
            PointLayout layout   = Layout;
            DimTypeList typelist = layout.Types;

            byte[]          data      = GetAllPackedPoints(typelist, out size);
            List <Vector3d> positions = new List <Vector3d>();
            List <Vector3f> colors    = new List <Vector3f>();

            uint pointSize = layout.PointSize;
            Dictionary <string, int>    indexs = new Dictionary <string, int>();
            Dictionary <string, string> types  = new Dictionary <string, string>();
            int  count    = 0;
            bool hasColor = false;

            for (uint j = 0; j < typelist.Size; j++)
            {
                DimType type = typelist.at(j);
                string  interpretationName      = type.InterpretationName;
                int     interpretationByteCount = type.InterpretationByteCount;
                string  name = type.IdName;
                indexs.Add(name, count);
                types.Add(name, interpretationName);
                if (name == "Red")
                {
                    hasColor = true;
                }
                count += interpretationByteCount;
            }

            for (long i = 0; i < (long)size; i += pointSize)
            {
                positions.Add(new Vector3d(parseDouble(data, types["X"], (int)(i + indexs["X"])),
                                           parseDouble(data, types["Y"], (int)(i + indexs["Y"])),
                                           parseDouble(data, types["Z"], (int)(i + indexs["Z"]))
                                           ));
                if (hasColor)
                {
                    colors.Add(new Vector3f((float)parseColor(data, types["Red"], (int)(i + indexs["Red"])),
                                            (float)parseColor(data, types["Green"], (int)(i + indexs["Green"])),
                                            (float)parseColor(data, types["Blue"], (int)(i + indexs["Blue"]))
                                            ));
                }
            }

            pc.positions = positions;
            pc.colors    = colors;
            pc.size      = (int)size;
            return(pc);
        }
예제 #4
0
        public byte[] GetAllPackedPoints(DimTypeList dims, out ulong size)
        {
            byte[] data = null;
            size = 0;

            if (this.Size > 0 && dims != null && dims.Size > 0)
            {
                ulong byteCount = this.Size * dims.ByteCount;
                data = new byte[byteCount];
                size = getAllPackedPoints(mNative, dims.Native, data);
            }

            return(data);
        }