CGAL 6.0.1 - Point Set Processing
Loading...
Searching...
No Matches
Point_set_processing_3/read_las_example.cpp
#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 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::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;
}
bool read_LAS_with_properties(std::istream &is, PointOutputIterator output, PropertyHandler &&... properties)
reads user-selected points properties from a .las or .laz stream.
Definition: read_las_points.h:378
std::tuple< PointMap, typename Kernel_traits< typename PointMap::value_type >::Kernel::Construct_point_3, LAS_property::X, LAS_property::Y, LAS_property::Z > make_las_point_reader(PointMap point_map)
generates a LAS property handler to read 3D points.
Definition: read_las_points.h:139