CGAL 6.1 - Point Set Processing
Loading...
Searching...
No Matches
Point_set_processing_3/orient_scanlines_example.cpp
#include <CGAL/Simple_cartesian.h>
#include <CGAL/IO/read_las_points.h>
#include <CGAL/IO/write_ply_points.h>
#include <CGAL/jet_estimate_normals.h>
#include <CGAL/scanline_orient_normals.h>
using Point_with_info = std::tuple<Point_3, Vector_3, float, unsigned char>;
void dump (const char* filename, const std::vector<Point_with_info>& points)
{
std::ofstream ofile (filename, std::ios::binary);
(ofile, points,
CGAL::parameters::point_map (Point_map()).
normal_map (Normal_map()));
}
int main (int argc, char** argv)
{
std::string fname (argc > 1 ? argv[1] : "data/urban.las");
std::vector<Point_with_info> points;
std::cerr << "Reading input file " << fname << std::endl;
std::ifstream ifile (fname, std::ios::binary);
if (!ifile ||
(ifile, std::back_inserter (points),
std::make_pair (Scan_angle_map(),
CGAL::IO::LAS_property::Scan_angle()),
std::make_pair (Scanline_id_map(),
CGAL::IO::LAS_property::Scan_direction_flag())))
{
std::cerr << "Can't read " << fname << std::endl;
return EXIT_FAILURE;
}
std::cerr << "Estimating normals" << std::endl;
CGAL::jet_estimate_normals<CGAL::Parallel_if_available_tag>
(points, 12,
CGAL::parameters::point_map (Point_map()).
normal_map (Normal_map()));
std::cerr << "Orienting normals using scan angle and direction flag" << std::endl;
(points,
CGAL::parameters::point_map (Point_map()).
normal_map (Normal_map()).
scan_angle_map (Scan_angle_map()).
scanline_id_map (Scanline_id_map()));
dump("out_angle_and_flag.ply", points);
std::cerr << "Orienting normals using scan direction flag only" << std::endl;
(points,
CGAL::parameters::point_map (Point_map()).
normal_map (Normal_map()).
scanline_id_map (Scanline_id_map()));
dump("out_flag.ply", points);
std::cerr << "Orienting normals using scan angle only" << std::endl;
(points,
CGAL::parameters::point_map (Point_map()).
normal_map (Normal_map()).
scan_angle_map (Scan_angle_map()));
dump("out_angle.ply", points);
std::cerr << "Orienting normals using no additional info" << std::endl;
(points,
CGAL::parameters::point_map (Point_map()).
normal_map (Normal_map()));
dump("out_nothing.ply", points);
return EXIT_SUCCESS;
}
void scanline_orient_normals(PointRange &points, const NamedParameters &np=parameters::default_values())
orients the normals of the range of points by estimating a line of sight and checking its consistency...
Definition: scanline_orient_normals.h:461
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
bool write_PLY(std::ostream &out, const PointRange &points, const PolygonRange &polygons, const NamedParameters &np=parameters::default_values())
Mode set_binary_mode(std::ios &s)