File: read_las_example.cpp

package info (click to toggle)
cgal 6.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 144,912 kB
  • sloc: cpp: 810,858; ansic: 208,477; sh: 493; python: 411; makefile: 286; javascript: 174
file content (41 lines) | stat: -rw-r--r-- 1,647 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>

#include <CGAL/property_map.h>
#include <CGAL/IO/read_las_points.h>

#include <utility>
#include <vector>
#include <fstream>

// types
typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel;
typedef Kernel::FT FT;
typedef Kernel::Point_3 Point;
typedef std::array<unsigned short, 4> Color;
typedef std::pair<Point, Color> PointWithColor;

int main(int argc, char*argv[])
{
  const char* fname = (argc>1) ? argv[1] : "data/pig_points.las";

  // Reads a .las point set file with normal vectors and colors
  std::ifstream in(fname, std::ios_base::binary);
  std::vector<PointWithColor> points; // store points
  if (!CGAL::IO::read_LAS_with_properties(in, std::back_inserter(points),
                                         CGAL::IO::make_las_point_reader(CGAL::First_of_pair_property_map<PointWithColor>()),
                                         std::make_tuple(CGAL::Second_of_pair_property_map<PointWithColor>(),
                                                         CGAL::Construct_array(),
                                                         CGAL::IO::LAS_property::R(),
                                                         CGAL::IO::LAS_property::G(),
                                                         CGAL::IO::LAS_property::B(),
                                                         CGAL::IO::LAS_property::I())))
  {
    std::cerr << "Error: cannot read file " << fname << std::endl;
    return EXIT_FAILURE;
  }

  for(std::size_t i = 0; i < points.size(); ++ i)
    std::cout << points[i].first << std::endl;

  return EXIT_SUCCESS;
}