mirror of https://github.com/CGAL/cgal
WIP Point_set
This commit is contained in:
parent
386fbb760d
commit
03487c4ce5
|
|
@ -17,31 +17,61 @@
|
|||
|
||||
|
||||
namespace CGAL {
|
||||
|
||||
template <typename Point,
|
||||
typename Vector>
|
||||
typename Vector,
|
||||
typename NamedParameters>
|
||||
bool read_point_set(const std::string& fname,
|
||||
CGAL::Point_set_3<Point, Vector>& ps)
|
||||
CGAL::Point_set_3<Point, Vector>& ps,
|
||||
const NamedParameters& np)
|
||||
{
|
||||
if (fname.find(".xyz") != std::string::npos) {
|
||||
return read_XYZ(fname, ps);
|
||||
return read_XYZ(fname, ps, np);
|
||||
}
|
||||
|
||||
if (fname.find(".off") != std::string::npos) {
|
||||
return read_OFF(fname, ps);
|
||||
return read_OFF(fname, ps, np);
|
||||
}
|
||||
|
||||
if (fname.find(".ply") != std::string::npos) {
|
||||
return read_PLY(fname, ps);
|
||||
return read_PLY(fname, ps, np);
|
||||
}
|
||||
|
||||
#ifdef CGAL_LINKED_WITH_LASLIB
|
||||
if (fname.find(".las") != std::string::npos) {
|
||||
return read_LAS(fname, ps);
|
||||
return read_LAS(fname, ps, np);
|
||||
}
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
template <typename Point,
|
||||
typename Vector>
|
||||
bool read_point_set(const std::string& fname,
|
||||
CGAL::Point_set_3<Point, Vector>& ps)
|
||||
{
|
||||
return read_point_set(fname, ps, parameters::all_default());
|
||||
}
|
||||
|
||||
template <typename Point,
|
||||
typename Vector,
|
||||
typename NamedParameters>
|
||||
bool read_point_set(const char* fname,
|
||||
CGAL::Point_set_3<Point, Vector>& ps,
|
||||
const NamedParameters& np)
|
||||
{
|
||||
return read_point_set(std::string(fname),
|
||||
ps,
|
||||
np);
|
||||
}
|
||||
|
||||
template <typename Point,
|
||||
typename Vector>
|
||||
bool read_point_set(const char* fname,
|
||||
CGAL::Point_set_3<Point, Vector>& ps)
|
||||
{
|
||||
return read_point_set(fname, ps, parameters::all_default());
|
||||
}
|
||||
|
||||
template <typename Point,
|
||||
typename Vector>
|
||||
|
|
|
|||
|
|
@ -470,7 +470,24 @@ bool read_LAS(std::istream& stream,
|
|||
}
|
||||
|
||||
/// \cond SKIP_IN_MANUAL
|
||||
// variant with default NP
|
||||
template < typename OutputIterator,
|
||||
#ifdef DOXYGEN_RUNNING
|
||||
typename NamedParameters
|
||||
#else
|
||||
typename CGAL_BGL_NP_TEMPLATE_PARAMETERS
|
||||
#endif
|
||||
>
|
||||
bool read_LAS(std::istream& stream,
|
||||
OutputIterator output,
|
||||
#ifdef DOXYGEN_RUNNING
|
||||
const NamedParameters& np)
|
||||
#else
|
||||
const CGAL_BGL_NP_CLASS& np)
|
||||
#endif
|
||||
{
|
||||
return read_LAS_with_properties(stream, output, np);
|
||||
}
|
||||
// variants with default NP
|
||||
template <typename OutputIteratorValueType,
|
||||
typename OutputIterator>
|
||||
bool
|
||||
|
|
@ -482,7 +499,23 @@ read_LAS(
|
|||
(stream, output, CGAL::parameters::all_default());
|
||||
}
|
||||
|
||||
// variant with default output iterator value type
|
||||
template < typename OutputIteratorValueType,
|
||||
typename OutputIterator>
|
||||
bool read_LAS(const std::string& fname,
|
||||
OutputIterator output)
|
||||
{
|
||||
return read_LAS<OutputIteratorValueType>(fname, output, parameters::all_default());
|
||||
}
|
||||
|
||||
template < typename OutputIteratorValueType,
|
||||
typename OutputIterator>
|
||||
bool read_LAS(const char* fname,
|
||||
OutputIterator output)
|
||||
{
|
||||
return read_LAS<OutputIteratorValueType>(fname, output, parameters::all_default());
|
||||
}
|
||||
|
||||
// variants with default output iterator value type
|
||||
template <typename OutputIterator,
|
||||
typename CGAL_BGL_NP_TEMPLATE_PARAMETERS>
|
||||
bool
|
||||
|
|
@ -495,20 +528,119 @@ read_LAS(
|
|||
(stream, output, np);
|
||||
}
|
||||
|
||||
// variant with default NP and output iterator value type
|
||||
template <typename OutputIterator,typename CGAL_BGL_NP_TEMPLATE_PARAMETERS>
|
||||
bool read_LAS(const char* fname,
|
||||
OutputIterator output,
|
||||
const CGAL_BGL_NP_CLASS& np)
|
||||
{
|
||||
std::ifstream is(fname);
|
||||
return read_LAS<typename value_type_traits<OutputIterator>::type>(is, output, np);
|
||||
}
|
||||
|
||||
template <typename OutputIterator, typename CGAL_BGL_NP_TEMPLATE_PARAMETERS>
|
||||
bool read_LAS(const std::string& fname,
|
||||
OutputIterator output,
|
||||
const CGAL_BGL_NP_CLASS& np)
|
||||
{
|
||||
return read_LAS<typename value_type_traits<OutputIterator>::type>(fname.c_str(), output, np);
|
||||
}
|
||||
|
||||
// variants with default NP and output iterator value type
|
||||
template <typename OutputIterator>
|
||||
bool
|
||||
read_LAS(
|
||||
std::istream& stream, ///< input stream.
|
||||
OutputIterator output,
|
||||
typename boost::enable_if<
|
||||
typename CGAL::is_iterator<OutputIterator>
|
||||
>::type* =0)
|
||||
OutputIterator output)
|
||||
{
|
||||
return read_LAS<typename value_type_traits<OutputIterator>::type>
|
||||
(stream, output, CGAL::parameters::all_default());
|
||||
}
|
||||
|
||||
template < typename OutputIterator>
|
||||
bool read_LAS(const std::string& fname,
|
||||
OutputIterator output)
|
||||
{
|
||||
return read_LAS<typename value_type_traits<OutputIterator>::type>(fname, output, parameters::all_default());
|
||||
}
|
||||
|
||||
template <typename OutputIterator>
|
||||
bool read_LAS(const char* fname,
|
||||
OutputIterator output)
|
||||
{
|
||||
return read_LAS<typename value_type_traits<OutputIterator>::type>(fname, output, parameters::all_default());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
\ingroup PkgPointSetProcessing3IOLas
|
||||
Reads points (position only) from a .las or .laz file.
|
||||
Potential additional properties are ignored.
|
||||
|
||||
\tparam OutputIteratorValueType type of objects that can be put in `OutputIterator`.
|
||||
It is default to `value_type_traits<OutputIterator>::%type` and can be omitted when the default is fine.
|
||||
\tparam OutputIterator iterator over output points.
|
||||
|
||||
\param stream input stream.
|
||||
\param output output iterator over points.
|
||||
|
||||
\param np optional sequence of \ref psp_namedparameters "Named Parameters" among the ones listed below.
|
||||
|
||||
\cgalNamedParamsBegin
|
||||
\cgalParamBegin{point_map} a model of `WritablePropertyMap` with value type `geom_traits::Point_3`.
|
||||
If this parameter is omitted, `CGAL::Identity_property_map<geom_traits::Point_3>` is used.\cgalParamEnd
|
||||
\cgalParamBegin{geom_traits} an instance of a geometric traits class, model of `Kernel`\cgalParamEnd
|
||||
\cgalNamedParamsEnd
|
||||
|
||||
\return true on success.
|
||||
|
||||
\cgalRequiresCPP11
|
||||
*/
|
||||
template < typename OutputIteratorValueType,
|
||||
typename OutputIterator,
|
||||
#ifdef DOXYGEN_RUNNING
|
||||
typename NamedParameters
|
||||
#else
|
||||
typename CGAL_BGL_NP_TEMPLATE_PARAMETERS
|
||||
#endif
|
||||
>
|
||||
bool read_LAS(const char* fname,
|
||||
OutputIterator output,
|
||||
#ifdef DOXYGEN_RUNNING
|
||||
const NamedParameters& np)
|
||||
#else
|
||||
const CGAL_BGL_NP_CLASS& np)
|
||||
#endif
|
||||
{
|
||||
std::ifstream is(fname);
|
||||
return read_LAS(is, output, np);
|
||||
}
|
||||
|
||||
template < typename OutputIteratorValueType,
|
||||
typename OutputIterator>
|
||||
bool read_LAS(const char* fname,
|
||||
OutputIterator output)
|
||||
{
|
||||
return read_LAS(fname, output, parameters::all_default());
|
||||
}
|
||||
|
||||
template < typename OutputIteratorValueType,
|
||||
typename OutputIterator,
|
||||
typename CGAL_BGL_NP_TEMPLATE_PARAMETERS>
|
||||
bool read_LAS(const std::string& fname,
|
||||
OutputIterator output,
|
||||
const CGAL_BGL_NP_CLASS& np)
|
||||
{
|
||||
return read_LAS(fname.c_str(), output, np);
|
||||
}
|
||||
|
||||
template < typename OutputIteratorValueType,
|
||||
typename OutputIterator>
|
||||
bool read_LAS(const std::string& fname,
|
||||
OutputIterator output)
|
||||
{
|
||||
return read_LAS(fname, output, parameters::all_default());
|
||||
}
|
||||
|
||||
#ifndef CGAL_NO_DEPRECATED_CODE
|
||||
// deprecated API
|
||||
template < typename OutputIteratorValueType,
|
||||
|
|
|
|||
|
|
@ -185,47 +185,147 @@ read_OFF(
|
|||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
\ingroup PkgPointSetProcessing3IO
|
||||
Reads points (positions + normals, if available) from a .off ASCII file.
|
||||
The function expects for each point a line with the x y z position,
|
||||
optionally followed by the nx ny nz normal.
|
||||
Faces are ignored.
|
||||
|
||||
\tparam OutputIteratorValueType type of objects that can be put in `OutputIterator`.
|
||||
It is default to `value_type_traits<OutputIterator>::%type` and can be omitted when the default is fine.
|
||||
\tparam OutputIterator iterator over output points.
|
||||
|
||||
\param stream input stream.
|
||||
\param output output iterator over points.
|
||||
\param np optional sequence of \ref psp_namedparameters "Named Parameters" among the ones listed below.
|
||||
|
||||
\cgalNamedParamsBegin
|
||||
\cgalParamBegin{point_map} a model of `WritablePropertyMap` with value type `geom_traits::Point_3`.
|
||||
If this parameter is omitted, `CGAL::Identity_property_map<geom_traits::Point_3>` is used.\cgalParamEnd
|
||||
\cgalParamBegin{normal_map} a model of `ReadWritePropertyMap` with value type
|
||||
`geom_traits::Vector_3`. If this parameter is omitted, normals in the input stream are
|
||||
ignored.\cgalParamEnd
|
||||
\cgalParamBegin{geom_traits} an instance of a geometric traits class, model of `Kernel`\cgalParamEnd
|
||||
\cgalNamedParamsEnd
|
||||
|
||||
\return true on success.
|
||||
*/
|
||||
template < typename OutputIteratorValueType,
|
||||
typename OutputIterator,
|
||||
#ifdef DOXYGEN_RUNNING
|
||||
typename NamedParameters
|
||||
#else
|
||||
typename CGAL_BGL_NP_TEMPLATE_PARAMETERS
|
||||
#endif
|
||||
>
|
||||
bool read_OFF(const char* fname,
|
||||
OutputIterator output,
|
||||
#ifdef DOXYGEN_RUNNING
|
||||
const NamedParameters& np)
|
||||
#else
|
||||
const CGAL_BGL_NP_CLASS& np)
|
||||
#endif
|
||||
{
|
||||
std::ifstream is(fname);
|
||||
return read_OFF(is, output, np);
|
||||
}
|
||||
|
||||
template < typename OutputIteratorValueType,
|
||||
typename OutputIterator,
|
||||
typename CGAL_BGL_NP_TEMPLATE_PARAMETERS>
|
||||
bool read_OFF(const std::string& fname,
|
||||
OutputIterator output,
|
||||
const CGAL_BGL_NP_CLASS& np)
|
||||
{
|
||||
return read_OFF<OutputIteratorValueType>(fname.c_str(), output, np);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// \cond SKIP_IN_MANUAL
|
||||
// variant with default NP
|
||||
// variants with default NP
|
||||
template <typename OutputIteratorValueType,
|
||||
typename OutputIterator>
|
||||
bool
|
||||
read_OFF(
|
||||
std::istream& stream, ///< input stream.
|
||||
OutputIterator output) ///< output iterator over points.
|
||||
std::istream& stream, ///< input stream.
|
||||
OutputIterator output) ///< output iterator over points.
|
||||
{
|
||||
return read_OFF<OutputIteratorValueType>
|
||||
(stream, output, CGAL::parameters::all_default());
|
||||
(stream, output, CGAL::parameters::all_default());
|
||||
}
|
||||
|
||||
// variant with default output iterator value type
|
||||
template < typename OutputIteratorValueType,
|
||||
typename OutputIterator>
|
||||
bool read_OFF(const std::string& fname,
|
||||
OutputIterator output)
|
||||
{
|
||||
return read_OFF<OutputIteratorValueType>(fname, output, parameters::all_default());
|
||||
}
|
||||
|
||||
template < typename OutputIteratorValueType,
|
||||
typename OutputIterator>
|
||||
bool read_OFF(const char* fname,
|
||||
OutputIterator output)
|
||||
{
|
||||
return read_OFF<OutputIteratorValueType>(fname, output, parameters::all_default());
|
||||
}
|
||||
|
||||
// variants with default output iterator value type
|
||||
template <typename OutputIterator,
|
||||
typename CGAL_BGL_NP_TEMPLATE_PARAMETERS>
|
||||
bool
|
||||
read_OFF(
|
||||
std::istream& stream, ///< input stream.
|
||||
OutputIterator output,
|
||||
const CGAL_BGL_NP_CLASS& np,
|
||||
typename boost::enable_if<
|
||||
CGAL::is_iterator<OutputIterator>
|
||||
>::type* =0)
|
||||
std::istream& stream, ///< input stream.
|
||||
OutputIterator output,
|
||||
const CGAL_BGL_NP_CLASS& np)
|
||||
{
|
||||
return read_OFF<typename value_type_traits<OutputIterator>::type>
|
||||
(stream, output, np);
|
||||
(stream, output, np);
|
||||
}
|
||||
|
||||
// variant with default NP and output iterator value type
|
||||
template <typename OutputIterator,typename CGAL_BGL_NP_TEMPLATE_PARAMETERS>
|
||||
bool read_OFF(const char* fname,
|
||||
OutputIterator output,
|
||||
const CGAL_BGL_NP_CLASS& np)
|
||||
{
|
||||
std::ifstream is(fname);
|
||||
return read_OFF<typename value_type_traits<OutputIterator>::type>(is, output, np);
|
||||
}
|
||||
|
||||
template <typename OutputIterator, typename CGAL_BGL_NP_TEMPLATE_PARAMETERS>
|
||||
bool read_OFF(const std::string& fname,
|
||||
OutputIterator output,
|
||||
const CGAL_BGL_NP_CLASS& np)
|
||||
{
|
||||
return read_OFF<typename value_type_traits<OutputIterator>::type>(fname.c_str(), output, np);
|
||||
}
|
||||
|
||||
// variants with default NP and output iterator value type
|
||||
template <typename OutputIterator>
|
||||
bool
|
||||
read_OFF(
|
||||
std::istream& stream, ///< input stream.
|
||||
OutputIterator output,
|
||||
typename std::enable_if<
|
||||
CGAL::is_iterator<OutputIterator>::value
|
||||
>::type* =0)
|
||||
OutputIterator output)
|
||||
{
|
||||
return read_OFF<typename value_type_traits<OutputIterator>::type>
|
||||
(stream, output, CGAL::parameters::all_default());
|
||||
(stream, output, CGAL::parameters::all_default());
|
||||
}
|
||||
|
||||
template < typename OutputIterator>
|
||||
bool read_OFF(const std::string& fname,
|
||||
OutputIterator output)
|
||||
{
|
||||
return read_OFF<typename value_type_traits<OutputIterator>::type>(fname, output, parameters::all_default());
|
||||
}
|
||||
|
||||
template <typename OutputIterator>
|
||||
bool read_OFF(const char* fname,
|
||||
OutputIterator output)
|
||||
{
|
||||
return read_OFF<typename value_type_traits<OutputIterator>::type>(fname, output, parameters::all_default());
|
||||
}
|
||||
|
||||
#ifndef CGAL_NO_DEPRECATED_CODE
|
||||
|
|
|
|||
|
|
@ -140,7 +140,7 @@ bool read_PLY_with_properties (std::istream& stream,
|
|||
return false;
|
||||
}
|
||||
|
||||
IO::internal::PLY_reader reader;
|
||||
IO::internal::PLY_reader reader(true);
|
||||
|
||||
if (!(reader.init (stream)))
|
||||
{
|
||||
|
|
@ -256,9 +256,65 @@ bool read_PLY(std::istream& stream,
|
|||
make_ply_point_reader (point_map));
|
||||
}
|
||||
|
||||
/**
|
||||
\ingroup PkgPointSetProcessing3IOPly
|
||||
Reads points (positions + normals, if available) from a .ply
|
||||
file (ASCII or binary).
|
||||
Potential additional point properties and faces are ignored.
|
||||
|
||||
\tparam OutputIteratorValueType type of objects that can be put in `OutputIterator`.
|
||||
It is default to `value_type_traits<OutputIterator>::%type` and can be omitted when the default is fine.
|
||||
\tparam OutputIterator iterator over output points.
|
||||
|
||||
\param stream input stream.
|
||||
\param output output iterator over points.
|
||||
\param np optional sequence of \ref psp_namedparameters "Named Parameters" among the ones listed below.
|
||||
|
||||
\cgalNamedParamsBegin
|
||||
\cgalParamBegin{point_map} a model of `WritablePropertyMap` with value type `geom_traits::Point_3`.
|
||||
If this parameter is omitted, `CGAL::Identity_property_map<geom_traits::Point_3>` is used.\cgalParamEnd
|
||||
\cgalParamBegin{normal_map} a model of `ReadWritePropertyMap` with value type
|
||||
`geom_traits::Vector_3`. If this parameter is omitted, normals in the input stream are
|
||||
ignored.\cgalParamEnd
|
||||
\cgalParamBegin{geom_traits} an instance of a geometric traits class, model of `Kernel`\cgalParamEnd
|
||||
\cgalNamedParamsEnd
|
||||
|
||||
\return true on success.
|
||||
|
||||
\cgalRequiresCPP11
|
||||
*/
|
||||
template < typename OutputIteratorValueType,
|
||||
typename OutputIterator,
|
||||
#ifdef DOXYGEN_RUNNING
|
||||
typename NamedParameters
|
||||
#else
|
||||
typename CGAL_BGL_NP_TEMPLATE_PARAMETERS
|
||||
#endif
|
||||
>
|
||||
bool read_PLY(const char* fname,
|
||||
OutputIterator output,
|
||||
#ifdef DOXYGEN_RUNNING
|
||||
const NamedParameters& np)
|
||||
#else
|
||||
const CGAL_BGL_NP_CLASS& np)
|
||||
#endif
|
||||
{
|
||||
std::ifstream is(fname);
|
||||
return read_PLY<OutputIteratorValueType>(is, output, np);
|
||||
}
|
||||
|
||||
template < typename OutputIteratorValueType,
|
||||
typename OutputIterator,
|
||||
typename CGAL_BGL_NP_TEMPLATE_PARAMETERS>
|
||||
bool read_PLY(const std::string& fname,
|
||||
OutputIterator output,
|
||||
const CGAL_BGL_NP_CLASS& np)
|
||||
{
|
||||
return read_PLY<OutputIteratorValueType>(fname.c_str(), output, np);
|
||||
}
|
||||
|
||||
/// \cond SKIP_IN_MANUAL
|
||||
// variant with default NP
|
||||
// variants with default NP
|
||||
template <typename OutputIteratorValueType,
|
||||
typename OutputIterator>
|
||||
bool
|
||||
|
|
@ -270,7 +326,23 @@ read_PLY(
|
|||
(stream, output, CGAL::parameters::all_default());
|
||||
}
|
||||
|
||||
// variant with default output iterator value type
|
||||
template < typename OutputIteratorValueType,
|
||||
typename OutputIterator>
|
||||
bool read_PLY(const std::string& fname,
|
||||
OutputIterator output)
|
||||
{
|
||||
return read_PLY<OutputIteratorValueType>(fname, output, parameters::all_default());
|
||||
}
|
||||
|
||||
template < typename OutputIteratorValueType,
|
||||
typename OutputIterator>
|
||||
bool read_PLY(const char* fname,
|
||||
OutputIterator output)
|
||||
{
|
||||
return read_PLY<OutputIteratorValueType>(fname, output, parameters::all_default());
|
||||
}
|
||||
|
||||
// variants with default output iterator value type
|
||||
template <typename OutputIterator,
|
||||
typename CGAL_BGL_NP_TEMPLATE_PARAMETERS>
|
||||
bool
|
||||
|
|
@ -283,7 +355,24 @@ read_PLY(
|
|||
(stream, output, np);
|
||||
}
|
||||
|
||||
// variant with default NP and output iterator value type
|
||||
template <typename OutputIterator,typename CGAL_BGL_NP_TEMPLATE_PARAMETERS>
|
||||
bool read_PLY(const char* fname,
|
||||
OutputIterator output,
|
||||
const CGAL_BGL_NP_CLASS& np)
|
||||
{
|
||||
std::ifstream is(fname);
|
||||
return read_PLY<typename value_type_traits<OutputIterator>::type>(is, output, np);
|
||||
}
|
||||
|
||||
template <typename OutputIterator, typename CGAL_BGL_NP_TEMPLATE_PARAMETERS>
|
||||
bool read_PLY(const std::string& fname,
|
||||
OutputIterator output,
|
||||
const CGAL_BGL_NP_CLASS& np)
|
||||
{
|
||||
return read_PLY<typename value_type_traits<OutputIterator>::type>(fname.c_str(), output, np);
|
||||
}
|
||||
|
||||
// variants with default NP and output iterator value type
|
||||
template <typename OutputIterator>
|
||||
bool
|
||||
read_PLY(
|
||||
|
|
@ -294,6 +383,20 @@ read_PLY(
|
|||
(stream, output, CGAL::parameters::all_default());
|
||||
}
|
||||
|
||||
template < typename OutputIterator>
|
||||
bool read_PLY(const std::string& fname,
|
||||
OutputIterator output)
|
||||
{
|
||||
return read_PLY<typename value_type_traits<OutputIterator>::type>(fname, output, parameters::all_default());
|
||||
}
|
||||
|
||||
template <typename OutputIterator>
|
||||
bool read_PLY(const char* fname,
|
||||
OutputIterator output)
|
||||
{
|
||||
return read_PLY<typename value_type_traits<OutputIterator>::type>(fname, output, parameters::all_default());
|
||||
}
|
||||
|
||||
#ifndef CGAL_NO_DEPRECATED_CODE
|
||||
// deprecated API
|
||||
template < typename OutputIteratorValueType,
|
||||
|
|
|
|||
|
|
@ -0,0 +1,115 @@
|
|||
// 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_READ_POINTS_H
|
||||
#define CGAL_READ_POINTS_H
|
||||
|
||||
#ifdef CGAL_LINKED_WITH_LASLIB
|
||||
#include <CGAL/IO/read_las_points.h>
|
||||
#endif
|
||||
#include <CGAL/IO/read_off_points.h>
|
||||
#include <CGAL/IO/read_ply_points.h>
|
||||
#include <CGAL/IO/read_xyz_points.h>
|
||||
|
||||
namespace CGAL {
|
||||
|
||||
template <typename OutputIteratorValueType,
|
||||
typename OutputIterator,
|
||||
typename NamedParameters>
|
||||
bool read_points(const std::string& fname,
|
||||
OutputIterator output,
|
||||
const NamedParameters& np)
|
||||
{
|
||||
if (fname.find(".xyz") != std::string::npos) {
|
||||
return read_XYZ<OutputIteratorValueType>(fname, output, np);
|
||||
}
|
||||
|
||||
if (fname.find(".off") != std::string::npos) {
|
||||
return read_OFF<OutputIteratorValueType>(fname, output, np);
|
||||
}
|
||||
|
||||
if (fname.find(".ply") != std::string::npos) {
|
||||
return read_PLY<OutputIteratorValueType>(fname, output, np);
|
||||
}
|
||||
|
||||
#ifdef CGAL_LINKED_WITH_LASLIB
|
||||
if (fname.find(".las") != std::string::npos) {
|
||||
return read_LAS<OutputIteratorValueType>fname, output, np);
|
||||
}
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
//variant with default OutputIteratorType
|
||||
template <typename OutputIterator,
|
||||
typename NamedParameters>
|
||||
bool read_points(const std::string& fname,
|
||||
OutputIterator output,
|
||||
const NamedParameters& np)
|
||||
{
|
||||
return read_points<typename value_type_traits<OutputIterator>::type>(fname, output, np);
|
||||
}
|
||||
|
||||
//variant with default np
|
||||
template <typename OutputIteratorValueType,
|
||||
typename OutputIterator>
|
||||
bool read_points(const std::string& fname,
|
||||
OutputIterator output)
|
||||
{
|
||||
return read_points<OutputIteratorValueType>(fname, output, parameters::all_default());
|
||||
}
|
||||
|
||||
//variant with all default
|
||||
template<typename OutputIterator>
|
||||
bool read_points(const std::string& fname,
|
||||
OutputIterator output)
|
||||
{
|
||||
return read_points<typename value_type_traits<OutputIterator>::type>(fname, output, parameters::all_default());
|
||||
}
|
||||
|
||||
|
||||
//variants with char*
|
||||
|
||||
template <typename OutputIteratorValueType,
|
||||
typename OutputIterator,
|
||||
typename NamedParameters>
|
||||
bool read_points(const char* fname,
|
||||
OutputIterator output,
|
||||
const NamedParameters& np)
|
||||
{
|
||||
return read_points<OutputIteratorValueType>(std::string(fname), output, np);
|
||||
}
|
||||
|
||||
template <typename OutputIterator,
|
||||
typename NamedParameters>
|
||||
bool read_points(const char* fname,
|
||||
OutputIterator output,
|
||||
const NamedParameters& np)
|
||||
{
|
||||
return read_points<typename value_type_traits<OutputIterator>::type>(fname, output, np);
|
||||
}
|
||||
|
||||
template <typename OutputIteratorValueType,
|
||||
typename OutputIterator>
|
||||
bool read_points(const char* fname,
|
||||
OutputIterator output)
|
||||
{
|
||||
return read_points<OutputIteratorValueType>(fname, output, parameters::all_default());
|
||||
}
|
||||
|
||||
template<typename OutputIterator>
|
||||
bool read_points(const char* fname,
|
||||
OutputIterator output)
|
||||
{
|
||||
return read_points<typename value_type_traits<OutputIterator>::type>(fname, output, parameters::all_default());
|
||||
}
|
||||
}//end CGAL
|
||||
|
||||
#endif // CGAL_READ_POINTS_H
|
||||
|
|
@ -174,44 +174,145 @@ read_XYZ(
|
|||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
\ingroup PkgPointSetProcessing3IO
|
||||
Reads points (positions + normals, if available) from a .xyz ASCII file.
|
||||
The function expects for each point a line with the x y z position,
|
||||
optionally followed by the nx ny nz normal.
|
||||
The first line may contain the number of points in the file.
|
||||
Empty lines and comments starting by # character are allowed.
|
||||
|
||||
\tparam OutputIteratorValueType type of objects that can be put in `OutputIterator`.
|
||||
It is default to `value_type_traits<OutputIterator>::%type` and can be omitted when the default is fine.
|
||||
\tparam OutputIterator iterator over output points.
|
||||
|
||||
\param stream input stream.
|
||||
\param output output iterator over points.
|
||||
\param np optional sequence of \ref psp_namedparameters "Named Parameters" among the ones listed below.
|
||||
|
||||
\cgalNamedParamsBegin
|
||||
\cgalParamBegin{point_map} a model of `WritablePropertyMap` with value type `geom_traits::Point_3`.
|
||||
If this parameter is omitted, `CGAL::Identity_property_map<geom_traits::Point_3>` is used.\cgalParamEnd
|
||||
\cgalParamBegin{normal_map} a model of `ReadWritePropertyMap` with value type
|
||||
`geom_traits::Vector_3`. If this parameter is omitted, normals in the input stream are
|
||||
ignored.\cgalParamEnd
|
||||
\cgalParamBegin{geom_traits} an instance of a geometric traits class, model of `Kernel`\cgalParamEnd
|
||||
\cgalNamedParamsEnd
|
||||
|
||||
\return true on success.
|
||||
*/
|
||||
template < typename OutputIteratorValueType,
|
||||
typename OutputIterator,
|
||||
#ifdef DOXYGEN_RUNNING
|
||||
typename NamedParameters
|
||||
#else
|
||||
typename CGAL_BGL_NP_TEMPLATE_PARAMETERS
|
||||
#endif
|
||||
>
|
||||
bool read_XYZ(const char* fname,
|
||||
OutputIterator output,
|
||||
#ifdef DOXYGEN_RUNNING
|
||||
const NamedParameters& np)
|
||||
#else
|
||||
const CGAL_BGL_NP_CLASS& np)
|
||||
#endif
|
||||
{
|
||||
std::ifstream is(fname);
|
||||
return read_XYZ(is, output, np);
|
||||
}
|
||||
|
||||
/// \cond SKIP_IN_MANUAL
|
||||
// variant with default NP
|
||||
template < typename OutputIteratorValueType,
|
||||
typename OutputIterator,
|
||||
typename CGAL_BGL_NP_TEMPLATE_PARAMETERS
|
||||
>
|
||||
bool read_XYZ(const std::string& fname,
|
||||
OutputIterator output,
|
||||
const CGAL_BGL_NP_CLASS& np)
|
||||
{
|
||||
return read_XYZ<OutputIteratorValueType>(fname.c_str(), output, np);
|
||||
}
|
||||
// variants with default NP
|
||||
template <typename OutputIteratorValueType,
|
||||
typename OutputIterator>
|
||||
bool
|
||||
read_XYZ(
|
||||
std::istream& stream, ///< input stream.
|
||||
OutputIterator output) ///< output iterator over points.
|
||||
std::istream& stream, ///< input stream.
|
||||
OutputIterator output) ///< output iterator over points.
|
||||
{
|
||||
return read_XYZ<OutputIteratorValueType>
|
||||
(stream, output, CGAL::parameters::all_default());
|
||||
(stream, output, CGAL::parameters::all_default());
|
||||
}
|
||||
|
||||
// variant with default output iterator value type
|
||||
template < typename OutputIteratorValueType,
|
||||
typename OutputIterator>
|
||||
bool read_XYZ(const std::string& fname,
|
||||
OutputIterator output)
|
||||
{
|
||||
return read_XYZ<OutputIteratorValueType>(fname, output, parameters::all_default());
|
||||
}
|
||||
|
||||
template < typename OutputIteratorValueType,
|
||||
typename OutputIterator>
|
||||
bool read_XYZ(const char* fname,
|
||||
OutputIterator output)
|
||||
{
|
||||
return read_XYZ<OutputIteratorValueType>(fname, output, parameters::all_default());
|
||||
}
|
||||
|
||||
// variants with default output iterator value type
|
||||
template <typename OutputIterator,
|
||||
typename CGAL_BGL_NP_TEMPLATE_PARAMETERS>
|
||||
bool
|
||||
read_XYZ(
|
||||
std::istream& stream, ///< input stream.
|
||||
OutputIterator output,
|
||||
const CGAL_BGL_NP_CLASS& np)
|
||||
std::istream& stream, ///< input stream.
|
||||
OutputIterator output,
|
||||
const CGAL_BGL_NP_CLASS& np)
|
||||
{
|
||||
return read_XYZ<typename value_type_traits<OutputIterator>::type>
|
||||
(stream, output, np);
|
||||
(stream, output, np);
|
||||
}
|
||||
|
||||
// variant with default NP and output iterator value type
|
||||
template <typename OutputIterator,typename CGAL_BGL_NP_TEMPLATE_PARAMETERS>
|
||||
bool read_XYZ(const char* fname,
|
||||
OutputIterator output,
|
||||
const CGAL_BGL_NP_CLASS& np)
|
||||
{
|
||||
std::ifstream is(fname);
|
||||
return read_XYZ<typename value_type_traits<OutputIterator>::type>(is, output, np);
|
||||
}
|
||||
|
||||
template <typename OutputIterator, typename CGAL_BGL_NP_TEMPLATE_PARAMETERS>
|
||||
bool read_XYZ(const std::string& fname,
|
||||
OutputIterator output,
|
||||
const CGAL_BGL_NP_CLASS& np)
|
||||
{
|
||||
return read_XYZ<typename value_type_traits<OutputIterator>::type>(fname.c_str(), output, np);
|
||||
}
|
||||
|
||||
// variants with default NP and output iterator value type
|
||||
template <typename OutputIterator>
|
||||
bool
|
||||
read_XYZ(
|
||||
std::istream& stream, ///< input stream.
|
||||
OutputIterator output,
|
||||
typename boost::enable_if<
|
||||
CGAL::is_iterator<OutputIterator>
|
||||
>::type* =0)
|
||||
std::istream& stream, ///< input stream.
|
||||
OutputIterator output)
|
||||
{
|
||||
return read_XYZ<typename value_type_traits<OutputIterator>::type>
|
||||
(stream, output, CGAL::parameters::all_default());
|
||||
(stream, output, CGAL::parameters::all_default());
|
||||
}
|
||||
|
||||
template < typename OutputIterator>
|
||||
bool read_XYZ(const std::string& fname,
|
||||
OutputIterator output)
|
||||
{
|
||||
return read_XYZ<typename value_type_traits<OutputIterator>::type>(fname, output, parameters::all_default());
|
||||
}
|
||||
|
||||
template <typename OutputIterator>
|
||||
bool read_XYZ(const char* fname,
|
||||
OutputIterator output)
|
||||
{
|
||||
return read_XYZ<typename value_type_traits<OutputIterator>::type>(fname, output, parameters::all_default());
|
||||
}
|
||||
|
||||
#ifndef CGAL_NO_DEPRECATED_CODE
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -3,9 +3,11 @@
|
|||
#include <CGAL/property_map.h>
|
||||
#include <CGAL/IO/read_off_points.h>
|
||||
#include <CGAL/IO/read_xyz_points.h>
|
||||
#include <CGAL/IO/read_ply_points.h>
|
||||
|
||||
#include <CGAL/config.h>
|
||||
#include <CGAL/IO/read_ply_points.h>
|
||||
#include <CGAL/Point_set_3/point_set_io.h>
|
||||
#include <CGAL/IO/read_points.h>
|
||||
|
||||
#include <vector>
|
||||
#include <cassert>
|
||||
|
|
@ -62,6 +64,15 @@ bool read_ply (std::string s,
|
|||
normal_map(CGAL::Second_of_pair_property_map<PointVectorPair>()));
|
||||
}
|
||||
|
||||
bool read_ps(std::string s)
|
||||
{
|
||||
std::vector<PointVectorPair> pv_pairs;
|
||||
return CGAL::read_points(s,
|
||||
std::back_inserter(pv_pairs),
|
||||
CGAL::parameters::point_map(CGAL::First_of_pair_property_map<PointVectorPair>()).
|
||||
normal_map(CGAL::Second_of_pair_property_map<PointVectorPair>()));
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
std::cerr << "### There should be three errors following this line...\n";
|
||||
|
|
@ -110,5 +121,12 @@ int main()
|
|||
assert(pv_pairs[1] == std::make_pair(Point_3(3,3,3), Vector_3(4,4,4)));
|
||||
assert(pv_pairs[2] == std::make_pair(Point_3(5,5,5), Vector_3(6,6,6)));
|
||||
|
||||
assert(read_ps("data/read_test/ok_1.xyz"));
|
||||
assert(read_ps("data/read_test/ok_1.off"));
|
||||
assert(read_ps("data/read_test/simple.ply"));
|
||||
#ifdef CGAL_LINKED_WITH_LASLIB
|
||||
assert(read_ps("data/read_test/pig_points.las"));
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -381,7 +381,13 @@ bool read_PLY(const char* fname,
|
|||
template <typename PointRange, typename PolygonRange>
|
||||
bool read_PLY(const char* fname,
|
||||
PointRange& points,
|
||||
PolygonRange& polygons)
|
||||
PolygonRange& polygons
|
||||
#ifndef DOXYGEN_RUNNING
|
||||
,typename std::enable_if<
|
||||
CGAL::is_iterator<PolygonRange>::value
|
||||
>::type* =0
|
||||
#endif
|
||||
)
|
||||
{
|
||||
return read_PLY(fname, points, polygons, parameters::all_default());
|
||||
}
|
||||
|
|
@ -399,7 +405,13 @@ bool read_PLY(const std::string& fname,
|
|||
template <typename PointRange, typename PolygonRange>
|
||||
bool read_PLY(const std::string fname,
|
||||
PointRange& points,
|
||||
PolygonRange& polygons)
|
||||
PolygonRange& polygons
|
||||
#ifndef DOXYGEN_RUNNING
|
||||
,typename std::enable_if<
|
||||
CGAL::is_iterator<PolygonRange>::value
|
||||
>::type* =0
|
||||
#endif
|
||||
)
|
||||
{
|
||||
return read_PLY(fname, points, polygons, parameters::all_default());
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue