Example #1
0
 public override void read(byte[] buffer, int pos, ref PCD_PointBuilder pbb)
 {
     if (id > -1)
     {
         pbb.data[id] = (double)System.BitConverter.ToSingle(buffer, pos);
     }
 }
Example #2
0
 public override void readASCII(string str, ref PCD_PointBuilder pbb)
 {
     if (id > -1)
     {
         pbb.data[id] = System.Convert.ToSingle(str);
     }
 }
Example #3
0
 public virtual void readASCII(string str, ref PCD_PointBuilder pbb)
 {
     if (id > -1)
     {
         pbb.data[id] = null;
     }
 }
Example #4
0
 public virtual void read(byte[] buffer, int pos, ref PCD_PointBuilder pbb)
 {
     if (id > -1)
     {
         pbb.data[id] = null;
     }
 }
Example #5
0
 public override void read(byte[] buffer, int pos, ref PCD_PointBuilder pbb)
 {
     if (id > -1)
     {
         pbb.data[id] = (int)buffer[pos];
     }
 }
Example #6
0
 public override void read(byte[] buffer, int pos, ref PCD_PointBuilder pbb)
 {
 }
Example #7
0
        public bool Import(string path, out PointCloud pc, bool intensity = false)
        {
            pc = new PointCloud();

            string header;

            if (!OpenFile(path, out header))
            {
                return(false);
            }
            if (!ParseHeader(header))
            {
                if (this.br != null)
                {
                    this.br.Close();
                }
                return(false);
            }

            pc.UserDictionary.Set("width", this.width);
            pc.UserDictionary.Set("height", this.height);

            if (this.binary)
            {
                byte[] buffer;

                int log_step = this.num_points / 5;

                for (int i = 0; i < this.num_points; ++i)
                {
                    //if (i % log_step == 0)
                    //    if (UpdateLog != null)
                    //        UpdateLog(((double)i/this.num_points * 100.0).ToString("0.0") + "%");
                    int pos = 0;
                    PCD_PointBuilder pbb = new PCD_PointBuilder();
                    buffer = br.ReadBytes(this.psize);
                    for (int j = 0; j < this.fields.Count; ++j)
                    {
                        this.fields[j].read(buffer, pos, ref pbb);
                        pos += this.fields[j].size;
                    }
                    if (intensity)
                    {
                        pc.Add(pbb.Point() * scale, pbb.Normal(), System.Drawing.Color.FromArgb(pbb.Intensity()));
                    }
                    else
                    {
                        pc.Add(pbb.Point() * scale, pbb.Normal(), System.Drawing.Color.FromArgb(pbb.Color()));
                    }
                }
                this.br.Close();
                return(true);
            }
            else
            {
                // read all data into buffer
                byte[] buffer = br.ReadBytes((int)br.BaseStream.Length - (int)br.BaseStream.Position);

                // parse buffer as ASCII text
                string bufferStr = System.Text.Encoding.Default.GetString(buffer);

                // split string buffer into list of strings
                List <string> lines = new List <string>(bufferStr.Split('\n'));

                if (lines.Count != this.num_points)
                {
                    log += "Header data doesn't match up with number of data lines!\n";
                }

                // parse points from line data
                for (int i = 0; i < lines.Count; ++i)
                {
                    PCD_PointBuilder pbb    = new PCD_PointBuilder();
                    string[]         tokens = lines[i].Split((char[])null, StringSplitOptions.RemoveEmptyEntries);
                    //log += lines[i];
                    //log += " " + tokens.Length.ToString() + "\n";
                    if (tokens.Length != this.fields.Count)
                    {
                        continue;
                    }

                    for (int j = 0; j < this.fields.Count; ++j)
                    {
                        this.fields[j].readASCII(tokens[j], ref pbb);
                    }
                    if (intensity)
                    {
                        pc.Add(pbb.Point() * this.scale, pbb.Normal(), System.Drawing.Color.FromArgb(pbb.Intensity()));
                    }
                    else
                    {
                        pc.Add(pbb.Point() * this.scale, pbb.Normal(), System.Drawing.Color.FromArgb(pbb.Color()));
                    }
                }
                this.br.Close();
                return(true);
            }
        }