// Copyright (c) 2020 Geometry Factory // All rights reserved. // // This file is part of CGAL (www.cgal.org). // // $URL$ // $Id$ // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // // Author(s) : Maxime Gimeno #ifndef CGAL_POINT_SET_PROCESSING_READ_POINTS_H #define CGAL_POINT_SET_PROCESSING_READ_POINTS_H #include #include #include #include #include #ifdef CGAL_LINKED_WITH_LASLIB #include #endif #include #include namespace CGAL { /// \cond SKIP_IN_MANUAL template bool read_points(const std::string& fname, PointOutputIterator output, const NamedParameters& np) { const std::string ext = IO::internal::get_file_extension(fname); if(ext == "xyz") return read_XYZ(fname, output, np); else if(ext == "off") return read_OFF(fname, output, np); else if(ext == "ply") return read_PLY(fname, output, np); #ifdef CGAL_LINKED_WITH_LASLIB else if(ext == "las") return read_LAS(fname, output, np); #endif return false; } // variant with default OutputIteratorType template bool read_points(const std::string& fname, OutputIterator output, const NamedParameters& np) { return read_points::type>(fname, output, np); } template bool read_points(const std::string& fname, OutputIterator output) { return read_points(fname, output, parameters::all_default()); } // variant with all default template bool read_points(const std::string& fname, OutputIterator output) { return read_points::type>(fname, output, parameters::all_default()); } /// \endcond /** \ingroup PkgPointSetProcessing3IO \brief reads the point set from an input file. Supported file formats are the following: - \ref IOStreamOFF (`.off`) - \ref IOStreamPLY (`.ply`) - \ref IOStreamLAS (`.las`) - \ref IOStreamXYZ (`.xyz`) The format is detected from the filename extension (letter case is not important). \tparam OutputIteratorValueType type of objects that can be put in `PointOutputIterator`. It defaults to `value_type_traits::%type` and can be omitted when the default is fine. \tparam PointOutputIterator iterator over output points. \tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters" \param fname the name of the input file. \param output output iterator over points. \param np optional sequence of \ref bgl_namedparameters "Named Parameters" among the ones listed below. \cgalNamedParamsBegin \cgalParamNBegin{point_map} \cgalParamDescription{a property map associating points to the elements of the point range} \cgalParamType{a model of `WritablePropertyMap` with value type `geom_traits::Point_3`} \cgalParamDefault{`CGAL::Identity_property_map`} \cgalParamNEnd \cgalParamNBegin{normal_map} \cgalParamDescription{a property map associating normals to the elements of the point range} \cgalParamType{a model of `WritablePropertyMap` with value type `geom_traits::Vector_3`} \cgalParamDefault{If this parameter is omitted, normals in the input stream are ignored.} \cgalParamNEnd \cgalParamNBegin{geom_traits} \cgalParamDescription{an instance of a geometric traits class} \cgalParamType{a model of `Kernel`} \cgalParamDefault{a \cgal Kernel deduced from the point type, using `CGAL::Kernel_traits`} \cgalParamNEnd \cgalParamNBegin{use_binary_mode} \cgalParamDescription{indicates whether data should be read in binary (`true`) or in ASCII (`false`)} \cgalParamType{Boolean} \cgalParamDefault{`true`} \cgalParamExtra{This parameter is only relevant for `PLY` reading: the `OFF` and `XYZ` formats are always ASCII, and the `LAS` format is always binary.} \cgalParamNEnd \cgalNamedParamsEnd \returns `true` if reading was successful, `false` otherwise. */ template bool read_points(const char* fname, PointOutputIterator output, const NamedParameters& np) { return read_points(std::string(fname), output, np); } /// \cond SKIP_IN_MANUAL template bool read_points(const char* fname, OutputIterator output, const NamedParameters& np) { return read_points::type>(fname, output, np); } template bool read_points(const char* fname, OutputIterator output) { return read_points(fname, output, parameters::all_default()); } template bool read_points(const char* fname, OutputIterator output) { return read_points::type>(fname, output, parameters::all_default()); } /// \endcond } // namespace CGAL #endif // CGAL_POINT_SET_PROCESSING_READ_POINTS_H