Point_set: move IO code to Stream_support (#9109)

## Summary of Changes

Make `Point_set_3` independent from `Point_set_processing`. No API
changes and no changes in `#include` directories.

## Release Management

* Affected package(s):  Point_set, Point_set_processing, Stream_support
* Issue(s) solved (if any): fix #0000, fix #0000,...
* Feature/Small Feature (if any):
* Link to compiled documentation (obligatory for small feature) [*wrong
link name to be changed*](httpssss://wrong_URL_to_be_changed/Manual/Pkg)
* License and copyright ownership: Some files change from GPL to LGPL,
so I hope @palliez is ok.
This commit is contained in:
Sebastien Loriot 2025-12-03 11:49:27 +01:00 committed by GitHub
commit b8db056348
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
53 changed files with 2154 additions and 1700 deletions

View File

@ -8,7 +8,7 @@
#include <CGAL/bounding_box.h>
#include <CGAL/tags.h>
#include <CGAL/IO/read_points.h>
#include <CGAL/IO/write_ply_points.h>
#include <CGAL/IO/PLY.h>
#include <CGAL/Real_timer.h>

View File

@ -123,11 +123,11 @@ In the example below, we can see a query where:
</center>
\subsection subsecFrechetDistanceImageCredits Image Credits
\section subsecFrechetDistanceImageCredits Image Credits
The character image is a visualization of two data points from the <a href="https://archive.ics.uci.edu/dataset/175/character+trajectories">Character Trajectories</a> data set.
\subsection subsecFrechetDistanceImplementation Implementation History
\section subsecFrechetDistanceImplementation Implementation History
An initial version using floating point arithmetic was developed by the authors
while working at the Max-Planck Institute for Informatics in Saarbrücken, Germany.

View File

@ -25,7 +25,6 @@ Modular_arithmetic
Number_types
Orthtree
Point_set_3
Point_set_processing_3
Polygon
Polygon_mesh_processing
Principal_component_analysis

View File

@ -26,7 +26,6 @@ Modular_arithmetic
Number_types
Orthtree
Point_set_3
Point_set_processing_3
Polygon
Polygon_mesh_processing
Principal_component_analysis

View File

@ -1,2 +1,7 @@
@INCLUDE = ${CGAL_DOC_PACKAGE_DEFAULTS}
PROJECT_NAME = "CGAL ${CGAL_DOC_VERSION} - 3D Point Set"
EXTRACT_ALL = false
HIDE_UNDOC_MEMBERS = true
HIDE_UNDOC_CLASSES = true

View File

@ -43,9 +43,6 @@
/// I/O Functions for the \ref IOStreamXYZ
/// \ingroup PkgPointSet3IO
/// \defgroup PkgPointSet3IODeprecated Input/Output (Deprecated)
/// \ingroup PkgPointSet3IO
/// These I/O functions are deprecated and newer versions should be used.
/*!
\addtogroup PkgPointSet3Ref

View File

@ -13,10 +13,8 @@
#include <CGAL/license/Point_set_3.h>
#ifdef CGAL_LINKED_WITH_LASLIB
#include <CGAL/IO/read_las_points.h>
#include <CGAL/IO/write_las_points.h>
#endif // LAS
#include <CGAL/IO/LAS/read_las_points.h>
#include <CGAL/IO/LAS/write_las_points.h>
#include <fstream>
#include <string>

View File

@ -16,8 +16,8 @@
#include <CGAL/Named_function_parameters.h>
#include <CGAL/boost/graph/named_params_helper.h>
#include <CGAL/IO/helpers.h>
#include <CGAL/IO/read_off_points.h>
#include <CGAL/IO/write_off_points.h>
#include <CGAL/IO/OFF/read_off_points.h>
#include <CGAL/IO/OFF/write_off_points.h>
#include <fstream>
#include <string>

View File

@ -15,8 +15,8 @@
#include <CGAL/Named_function_parameters.h>
#include <CGAL/boost/graph/named_params_helper.h>
#include <CGAL/IO/read_xyz_points.h>
#include <CGAL/IO/write_xyz_points.h>
#include <CGAL/IO/XYZ/read_xyz_points.h>
#include <CGAL/IO/XYZ/write_xyz_points.h>
#include <fstream>
#include <string>

View File

@ -18,7 +18,6 @@ Kernel_d
Modular_arithmetic
Number_types
Point_set_3
Point_set_processing_3
Polygon
Profiling_tools
Property_map

View File

@ -1,7 +1,6 @@
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Point_set_3.h>
#include <CGAL/IO/write_xyz_points.h>
#include <CGAL/grid_simplify_point_set.h>
#include <fstream>

View File

@ -10,23 +10,6 @@ simplification, etc.).
\defgroup PkgPointSetProcessing3IO I/O Functions
\ingroup PkgPointSetProcessing3Ref
\defgroup PkgPointSetProcessing3IOOff I/O (OFF Formats)
\ingroup PkgPointSetProcessing3Ref
\defgroup PkgPointSetProcessing3IOXyz I/O (XYZ Formats)
\ingroup PkgPointSetProcessing3Ref
\defgroup PkgPointSetProcessing3IOPly I/O (PLY Format)
\ingroup PkgPointSetProcessing3Ref
Read and write points (with or without additional properties) in PLY
format.
\defgroup PkgPointSetProcessing3IOLas I/O (LAS Format)
\ingroup PkgPointSetProcessing3Ref
Read and write points (with or without additional properties) in LAS
format.
\addtogroup PkgPointSetProcessing3Ref
\cgalPkgDescriptionBegin{Point Set Processing,PkgPointSetProcessing3}
@ -84,14 +67,14 @@ format.
\cgalCRPSection{I/O (XYZ/OFF Formats)}
- \link PkgPointSetProcessing3IOOff OFF I/O Functions (`read_OFF()` and `write_OFF()`)\endlink
- \link PkgPointSetProcessing3IOXyz XYZ I/O Functions (`read_XYZ()` and `write_XYZ()`)\endlink
- \link PkgStreamSupportIoFuncsOFF OFF I/O Functions (`read_OFF()` and `write_OFF()`)\endlink
- \link PkgStreamSupportIoFuncsXYZ XYZ I/O Functions (`read_XYZ()` and `write_XYZ()`)\endlink
\cgalCRPSection{I/O (PLY Format)}
- \link PkgPointSetProcessing3IOPly `CGAL::IO::read_PLY()` \endlink
- \link PkgStreamSupportIoFuncsPLY `CGAL::IO::read_PLY()` \endlink
- `CGAL::IO::read_PLY_with_properties()`
- \link PkgPointSetProcessing3IOPly `CGAL::IO::write_PLY()` \endlink
- \link PkgStreamSupportIoFuncsPLY `CGAL::IO::write_PLY()` \endlink
- `CGAL::IO::write_PLY_with_properties()`
- `CGAL::IO::PLY_property<T>`
- `CGAL::IO::make_ply_point_reader()`

View File

@ -1,6 +1,7 @@
#include <CGAL/Simple_cartesian.h>
#include <CGAL/IO/read_las_points.h>
#include <CGAL/IO/write_ply_points.h>
#include <CGAL/Point_set_3/IO/LAS.h>
#include <CGAL/IO/LAS.h>
#include <CGAL/IO/PLY.h>
#include <CGAL/jet_estimate_normals.h>
#include <CGAL/scanline_orient_normals.h>

View File

@ -1,7 +1,7 @@
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/property_map.h>
#include <CGAL/IO/read_las_points.h>
#include <CGAL/IO/LAS.h>
#include <utility>
#include <vector>

View File

@ -1,7 +1,7 @@
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/property_map.h>
#include <CGAL/IO/read_ply_points.h>
#include <CGAL/IO/PLY.h>
#include <utility>
#include <vector>

View File

@ -1,8 +1,7 @@
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/property_map.h>
#include <CGAL/IO/read_xyz_points.h>
#include <CGAL/IO/write_xyz_points.h>
#include <CGAL/IO/XYZ.h>
#include <utility> // defines std::pair
#include <vector>

View File

@ -1,8 +1,7 @@
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/property_map.h>
#include <CGAL/IO/read_las_points.h>
#include <CGAL/IO/write_las_points.h>
#include <CGAL/IO/LAS.h>
#include <utility>
#include <vector>

View File

@ -1,7 +1,7 @@
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/property_map.h>
#include <CGAL/IO/write_ply_points.h>
#include <CGAL/IO/PLY.h>
#include <utility>
#include <vector>

View File

@ -1,367 +0,0 @@
// Copyright (c) 2015 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) : Simon Giraudot
#ifndef CGAL_POINT_SET_PROCESSING_READ_PLY_POINTS_H
#define CGAL_POINT_SET_PROCESSING_READ_PLY_POINTS_H
#include <CGAL/license/Point_set_processing_3.h>
#include <CGAL/config.h>
#include <CGAL/IO/PLY.h>
#include <CGAL/property_map.h>
#include <CGAL/value_type_traits.h>
#include <CGAL/Kernel_traits.h>
#include <CGAL/IO/io.h>
#include <CGAL/Named_function_parameters.h>
#include <CGAL/boost/graph/named_params_helper.h>
#include <boost/version.hpp>
#include <boost/cstdint.hpp>
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <tuple>
namespace CGAL {
namespace IO {
#ifdef DOXYGEN_RUNNING // Document some parts from Stream_support here for convenience
/**
\ingroup PkgPointSetProcessing3IOPly
Class used to identify a %PLY property as a type and a name.
\sa `read_PLY_with_properties()`
*/
template <typename T>
struct PLY_property
{
typedef T type;
const char* name;
PLY_property(const char* name) : name(name) { }
};
/**
\ingroup PkgPointSetProcessing3IOPly
Generates a %PLY property handler to read 3D points. Points are
constructed from the input using 3 %PLY properties of type `FT`
and named `x`, `y` and `z`. `FT` is `float` if the points use
`CGAL::Simple_cartesian<float>` and `double` otherwise.
\tparam PointMap the property map used to store points.
\sa `read_PLY_with_properties()`
\sa \ref IOStreamPLY
*/
template <typename PointMap>
std::tuple<PointMap,
typename Kernel_traits<typename PointMap::value_type>::Kernel::Construct_point_3,
PLY_property<FT>, PLY_property<FT>, PLY_property<FT> >
make_ply_point_reader(PointMap point_map);
/**
\ingroup PkgPointSetProcessing3IOPly
Generates a %PLY property handler to read 3D normal
vectors. Vectors are constructed from the input using 3 PLY
properties of type `FT` and named `nx`, `ny` and `nz`. `FT`
is `float` if the points use `CGAL::Simple_cartesian<float>` and
`double` otherwise.
\tparam VectorMap the property map used to store vectors.
\sa `read_PLY_with_properties()`
\sa \ref IOStreamPLY
*/
template <typename VectorMap>
std::tuple<VectorMap,
typename Kernel_traits<typename VectorMap::value_type>::Kernel::Construct_vector_3,
PLY_property<FT>, PLY_property<FT>, PLY_property<FT> >
make_ply_normal_reader(VectorMap normal_map);
#endif // DOXYGEN_RUNNING
/**
\ingroup PkgPointSetProcessing3IOPly
\brief reads user-selected points properties from a .ply stream (ASCII or binary).
Potential additional point properties and faces are ignored.
Properties are handled through a variadic list of property
handlers. A `PropertyHandler` can either be:
- A `std::pair<PropertyMap, PLY_property<T> >` if the user wants
to read a %PLY property as a scalar value T (for example, storing
an `int` %PLY property into an `int` variable).
- A `std::tuple<PropertyMap, Constructor,
PLY_property<T>...>` if the user wants to use one or several PLY
properties to construct a complex object (for example, storing 3
`uchar` %PLY properties into a %Color object that can for example
be a `std::array<unsigned char, 3>`). In that case, the
second element of the tuple should be a functor that constructs
the value type of `PropertyMap` from N objects of types `T`.
\attention To read a binary file, the flag `std::ios::binary` must be set during the creation of the `ifstream`.
\tparam OutputIteratorValueType type of objects that can be put in `PointOutputIterator`.
It must be a model of `DefaultConstructible` and defaults to `value_type_traits<PointOutputIterator>::%type`.
It can be omitted when the default is fine.
\tparam PointOutputIterator iterator over output points.
\tparam PropertyHandler handlers to recover properties.
\returns `true` if reading was successful, `false` otherwise.
\sa \ref IOStreamPLY
\sa `make_ply_point_reader()`
\sa `make_ply_normal_reader()`
*/
template <typename OutputIteratorValueType,
typename PointOutputIterator,
typename ... PropertyHandler>
bool read_PLY_with_properties(std::istream& is,
PointOutputIterator output,
PropertyHandler&& ... properties)
{
if(!is)
return false;
internal::PLY_reader reader(true);
if(!(reader.init(is)))
{
is.setstate(std::ios::failbit);
return false;
}
for(std::size_t i = 0; i < reader.number_of_elements(); ++ i)
{
internal::PLY_element& element = reader.element(i);
for(std::size_t j = 0; j < element.number_of_items(); ++ j)
{
for(std::size_t k = 0; k < element.number_of_properties(); ++ k)
{
internal::PLY_read_number* property = element.property(k);
property->get(is);
if(is.fail())
return false;
}
if(element.name() == "vertex" || element.name() == "vertices")
{
OutputIteratorValueType new_element;
internal::process_properties(element, new_element, std::forward<PropertyHandler>(properties)...);
*(output ++) = new_element;
}
}
}
return true;
}
/// \cond SKIP_IN_MANUAL
template <typename OutputIterator,
typename ... PropertyHandler>
bool read_PLY_with_properties(std::istream& is,
OutputIterator output,
PropertyHandler&& ... properties)
{
typedef typename value_type_traits<OutputIterator>::type OutputValueType;
return read_PLY_with_properties<OutputValueType>(is, output, std::forward<PropertyHandler>(properties)...);
}
/// \endcond
/**
\ingroup PkgPointSetProcessing3IOPly
\brief reads points (positions + normals, if available), using the \ref IOStreamPLY.
Potential additional point properties and faces are ignored.
\attention To read a binary file, the flag `std::ios::binary` must be set during the creation of the `ifstream`.
\tparam OutputIteratorValueType type of objects that can be put in `PointOutputIterator`.
It must be a model of `DefaultConstructible` and defaults to `value_type_traits<PointOutputIterator>::%type`.
It 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 is input stream.
\param output output iterator over points.
\param np an 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<geom_traits::Point_3>`}
\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
\cgalNamedParamsEnd
\returns `true` if reading was successful, `false` otherwise.
\sa `read_PLY_with_properties()`
*/
template <typename OutputIteratorValueType,
typename PointOutputIterator,
typename CGAL_NP_TEMPLATE_PARAMETERS>
bool read_PLY(std::istream& is,
PointOutputIterator output,
const CGAL_NP_CLASS& np = parameters::default_values()
#ifndef DOXYGEN_RUNNING
, std::enable_if_t<CGAL::is_iterator<PointOutputIterator>::value>* = nullptr
#endif
)
{
using parameters::choose_parameter;
using parameters::get_parameter;
typedef Point_set_processing_3::Fake_point_range<OutputIteratorValueType> PointRange;
// basic geometric types
typedef Point_set_processing_3_np_helper<PointRange, CGAL_NP_CLASS> NP_helper;
typedef typename NP_helper::Point_map PointMap;
typedef typename NP_helper::Normal_map NormalMap;
PointMap point_map = NP_helper::get_point_map(np);
NormalMap normal_map = NP_helper::get_normal_map(np);
return read_PLY_with_properties(is, output,
make_ply_point_reader(point_map),
make_ply_normal_reader(normal_map));
}
/**
\ingroup PkgPointSetProcessing3IOPly
\brief reads points (positions + normals, if available), using the \ref IOStreamPLY.
Potential additional point properties and faces are ignored.
\tparam OutputIteratorValueType type of objects that can be put in `PointOutputIterator`.
It must be a model of `DefaultConstructible` and defaults to `value_type_traits<PointOutputIterator>::%type`.
It 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 input file name.
\param output output iterator over points.
\param np optional sequence of \ref bgl_namedparameters "Named Parameters" among the ones listed below.
\cgalNamedParamsBegin
\cgalParamNBegin{use_binary_mode}
\cgalParamDescription{indicates whether data should be read in binary (`true`) or in \ascii (`false`)}
\cgalParamType{Boolean}
\cgalParamDefault{`true`}
\cgalParamNEnd
\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<geom_traits::Point_3>`}
\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
\cgalNamedParamsEnd
\returns `true` if reading was successful, `false` otherwise.
\sa \ref IOStreamPLY
\sa `read_PLY_with_properties()`
*/
template <typename OutputIteratorValueType,
typename PointOutputIterator,
typename CGAL_NP_TEMPLATE_PARAMETERS>
bool read_PLY(const std::string& fname,
PointOutputIterator output,
const CGAL_NP_CLASS& np = parameters::default_values()
#ifndef DOXYGEN_RUNNING
, std::enable_if_t<CGAL::is_iterator<PointOutputIterator>::value>* = nullptr
#endif
)
{
const bool binary = CGAL::parameters::choose_parameter(CGAL::parameters::get_parameter(np, internal_np::use_binary_mode), true);
if(binary)
{
std::ifstream is(fname, std::ios::binary);
CGAL::IO::set_mode(is, CGAL::IO::BINARY);
return read_PLY<OutputIteratorValueType>(is, output, np);
}
else
{
std::ifstream is(fname);
CGAL::IO::set_mode(is, CGAL::IO::ASCII);
return read_PLY<OutputIteratorValueType>(is, output, np);
}
}
/// \cond SKIP_IN_MANUAL
// variants with default output iterator value type
template <typename OutputIterator, typename CGAL_NP_TEMPLATE_PARAMETERS>
bool read_PLY(std::istream& is, OutputIterator output, const CGAL_NP_CLASS& np = parameters::default_values(),
std::enable_if_t<CGAL::is_iterator<OutputIterator>::value>* = nullptr)
{
return read_PLY<typename value_type_traits<OutputIterator>::type>(is, output, np);
}
template <typename OutputIterator,typename CGAL_NP_TEMPLATE_PARAMETERS>
bool read_PLY(const std::string& fname, OutputIterator output, const CGAL_NP_CLASS& np = parameters::default_values(),
std::enable_if_t<CGAL::is_iterator<OutputIterator>::value>* = nullptr)
{
return read_PLY<typename value_type_traits<OutputIterator>::type>(fname, output, np);
}
/// \endcond
} // namespace IO
} // namespace CGAL
#undef TRY_TO_GENERATE_POINT_PROPERTY
#undef TRY_TO_GENERATE_SIZED_FACE_PROPERTY
#undef TRY_TO_GENERATE_FACE_PROPERTY
#endif // CGAL_POINT_SET_PROCESSING_READ_PLY_POINTS_H

View File

@ -1,203 +0,0 @@
// Copyright (c) 2007-09 INRIA Sophia-Antipolis (France).
// 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) : Pierre Alliez and Laurent Saboret
#ifndef CGAL_POINT_SET_PROCESSING_WRITE_OFF_POINTS_H
#define CGAL_POINT_SET_PROCESSING_WRITE_OFF_POINTS_H
#include <CGAL/license/Point_set_processing_3.h>
#include <CGAL/IO/helpers.h>
#include <CGAL/IO/OFF.h>
#include <CGAL/Named_function_parameters.h>
#include <CGAL/boost/graph/named_params_helper.h>
#include <CGAL/property_map.h>
#include <CGAL/Iterator_range.h>
#include <CGAL/assertions.h>
#include <iostream>
#include <fstream>
#include <iterator>
#include <type_traits>
namespace CGAL {
namespace Point_set_processing_3 {
namespace internal {
template <typename PointRange, typename CGAL_NP_TEMPLATE_PARAMETERS>
bool write_OFF_PSP(std::ostream& os,
const PointRange& points,
const CGAL_NP_CLASS& np = CGAL::parameters::default_values())
{
using CGAL::parameters::is_default_parameter;
// basic geometric types
typedef Point_set_processing_3_np_helper<PointRange, CGAL_NP_CLASS> NP_helper;
typedef typename NP_helper::Const_point_map PointMap;
typedef typename NP_helper::Normal_map NormalMap;
const bool has_normals = NP_helper::has_normal_map(points, np);
PointMap point_map = NP_helper::get_const_point_map(points, np);
NormalMap normal_map = NP_helper::get_normal_map(points, np);
CGAL_precondition(points.begin() != points.end());
if(!os)
{
std::cerr << "Error: cannot open file" << std::endl;
return false;
}
set_stream_precision_from_NP(os, np);
// Write header
if (has_normals)
os << "NOFF" << std::endl;
else
os << "OFF" << std::endl;
os << points.size() << " 0 0" << std::endl;
// Write positions + normals
for(typename PointRange::const_iterator it = points.begin(); it != points.end(); it++)
{
os << get(point_map, *it);
if (has_normals)
os << " " << get(normal_map, *it);
os << "\n";
}
os << std::flush;
return !os.fail();
}
} // namespace internal
} // namespace Point_set_processing_3
namespace IO {
/**
\ingroup PkgPointSetProcessing3IOOff
\brief writes the range of `points` (positions + normals, if available), using the \ref IOStreamOFF.
\tparam PointRange is a model of `ConstRange`. The value type of
its iterator is the key type of the named parameter `point_map`.
\tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters"
\param os output stream
\param points input point range
\param np an 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 `ReadablePropertyMap` with value type `geom_traits::Point_3`}
\cgalParamDefault{`CGAL::Identity_property_map<geom_traits::Point_3>`}
\cgalParamNEnd
\cgalParamNBegin{normal_map}
\cgalParamDescription{a property map associating normals to the elements of the point range}
\cgalParamType{a model of `ReadablePropertyMap` with value type `geom_traits::Vector_3`}
\cgalParamDefault{If this parameter is omitted, normals are not written in the output stream.}
\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{stream_precision}
\cgalParamDescription{a parameter used to set the precision (i.e. how many digits are generated) of the output stream}
\cgalParamType{int}
\cgalParamDefault{the precision of the stream `os`}
\cgalParamNEnd
\cgalNamedParamsEnd
\returns `true` if writing was successful, `false` otherwise.
*/
template <typename PointRange, typename CGAL_NP_TEMPLATE_PARAMETERS>
bool write_OFF(std::ostream& os,
const PointRange& points,
const CGAL_NP_CLASS& np = parameters::default_values()
#ifndef DOXYGEN_RUNNING
, std::enable_if_t<internal::is_Range<PointRange>::value>* = nullptr
#endif
)
{
return Point_set_processing_3::internal::write_OFF_PSP(os, points, np);
}
/**
\ingroup PkgPointSetProcessing3IOOff
\brief writes the range of `points` (positions + normals, if available), using the \ref IOStreamOFF.
\tparam PointRange is a model of `ConstRange`. The value type of
its iterator is the key type of the named parameter `point_map`.
\tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters"
\param filename the path to the output file
\param points input point range
\param np an 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 `ReadablePropertyMap` with value type `geom_traits::Point_3`}
\cgalParamDefault{`CGAL::Identity_property_map<geom_traits::Point_3>`}
\cgalParamNEnd
\cgalParamNBegin{normal_map}
\cgalParamDescription{a property map associating normals to the elements of the point range}
\cgalParamType{a model of `ReadablePropertyMap` with value type `geom_traits::Vector_3`}
\cgalParamDefault{If this parameter is omitted, normals are not written in the output file.}
\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{stream_precision}
\cgalParamDescription{a parameter used to set the precision (i.e. how many digits are generated) of the output stream}
\cgalParamType{int}
\cgalParamDefault{`6`}
\cgalParamNEnd
\cgalNamedParamsEnd
\returns `true` if writing was successful, `false` otherwise.
\sa \ref IOStreamOFF
*/
template <typename PointRange,
typename CGAL_NP_TEMPLATE_PARAMETERS>
bool write_OFF(const std::string& filename,
const PointRange& points,
const CGAL_NP_CLASS& np = parameters::default_values()
#ifndef DOXYGEN_RUNNING
, std::enable_if_t<internal::is_Range<PointRange>::value>* = nullptr
#endif
)
{
std::ofstream os(filename);
set_stream_precision_from_NP(os, np);
return write_OFF(os, points, np);
}
} // IO namespace
} // namespace CGAL
#endif // CGAL_POINT_SET_PROCESSING_WRITE_OFF_POINTS_H

View File

@ -1,303 +0,0 @@
// Copyright (c) 2015 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) : Simon Giraudot
#ifndef CGAL_POINT_SET_PROCESSING_WRITE_PLY_POINTS_H
#define CGAL_POINT_SET_PROCESSING_WRITE_PLY_POINTS_H
#include <CGAL/license/Point_set_processing_3.h>
#include <CGAL/IO/helpers.h>
#include <CGAL/IO/PLY.h>
#include <CGAL/property_map.h>
#include <CGAL/assertions.h>
#include <CGAL/Iterator_range.h>
#include <CGAL/Named_function_parameters.h>
#include <CGAL/boost/graph/named_params_helper.h>
#include <boost/version.hpp>
#include <iostream>
#include <fstream>
#include <iterator>
#include <tuple>
#include <type_traits>
namespace CGAL {
namespace IO {
#ifdef DOXYGEN_RUNNING // Document some parts from Stream_support here for convenience
/**
\ingroup PkgPointSetProcessing3IOPly
Generates a %PLY property handler to write 3D points. Points are
written as 3 %PLY properties of type `FT` and named `x`, `y` and
`z`. `FT` is `float` if the points use
`CGAL::Simple_cartesian<float>` and `double` otherwise.
\tparam PointMap the property map used to store points.
\sa `write_PLY_with_properties()`
\sa \ref IOStreamPLY
*/
template <typename PointMap>
std::tuple<PointMap, PLY_property<FT>, PLY_property<FT>, PLY_property<FT> >
make_ply_point_writer(PointMap point_map);
/**
\ingroup PkgPointSetProcessing3IOPly
Generates a %PLY property handler to write 3D normal
vectors. Vectors are written as 3 %PLY properties of type `FT`
and named `nx`, `ny` and `nz`. `FT` is `float` if the vectors use
`CGAL::Simple_cartesian<float>` and `double` otherwise.
\tparam VectorMap the property map used to store vectors.
\sa `write_PLY_with_properties()`
\sa \ref IOStreamPLY
*/
template <typename VectorMap>
std::tuple<VectorMap, PLY_property<FT>, PLY_property<FT>, PLY_property<FT> >
make_ply_normal_writer(VectorMap normal_map);
#endif
/**
\ingroup PkgPointSetProcessing3IOPly
\brief writes the range of `points` with properties using \ref IOStreamPLY.
Properties are handled through a variadic list of property
handlers. A `PropertyHandler` can either be:
- A `std::pair<PropertyMap, PLY_property<T> >` if the user wants
to write a scalar value T as a %PLY property (for example, writing
an `int` variable as an `int` %PLY property).
- A `std::tuple<PropertyMap, PLY_property<T>...>` if the
user wants to write a complex object as several %PLY
properties. In that case, a specialization of `Output_rep` must
be provided for `PropertyMap::value_type` that handles both ASCII
and binary output (see `CGAL::IO::get_mode()`).
\attention To write to a binary file, the flag `std::ios::binary` must be set during the creation
of the `ofstream`, and the \link PkgStreamSupportEnumRef `IO::Mode` \endlink
of the stream must be set to `BINARY`.
\tparam PointRange is a model of `ConstRange`. The value type of
its iterator is the key type of the `PropertyMap` objects provided
within the `PropertyHandler` parameter.
\tparam PropertyHandler handlers to recover properties.
\returns `true` if writing was successful, `false` otherwise.
\sa \ref IOStreamPLY
\sa `make_ply_point_writer()`
\sa `make_ply_normal_writer()`
*/
template <typename PointRange,
typename ... PropertyHandler>
bool write_PLY_with_properties(std::ostream& os, ///< output stream.
const PointRange& points, ///< input point range.
PropertyHandler&& ... properties) ///< parameter pack of property handlers
{
CGAL_precondition(points.begin() != points.end());
if(!os)
{
std::cerr << "Error: cannot open file" << std::endl;
return false;
}
// Write header
os << "ply" << std::endl
<< ((get_mode(os) == BINARY) ? "format binary_little_endian 1.0" : "format ascii 1.0") << std::endl
<< "comment Generated by the CGAL library" << std::endl
<< "element vertex " << points.size() << std::endl;
internal::output_property_header (os, std::forward<PropertyHandler>(properties)...);
os << "end_header" << std::endl;
// Write positions + normals
for(typename PointRange::const_iterator it = points.begin(); it != points.end(); it++)
internal::output_properties (os, it, std::forward<PropertyHandler>(properties)...);
return !os.fail();
}
/**
\ingroup PkgPointSetProcessing3IOPly
\brief writes the range of `points` (positions + normals, if available) using \ref IOStreamPLY.
\attention To write to a binary file, the flag `std::ios::binary` must be set during the creation
of the `ofstream`, and the \link PkgStreamSupportEnumRef `IO::Mode` \endlink
of the stream must be set to `BINARY`.
\tparam PointRange is a model of `ConstRange`. The value type of
its iterator is the key type of the named parameter `point_map`.
\tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters"
\param os output stream
\param points input point range
\param np an 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 `ReadablePropertyMap` with value type `geom_traits::Point_3`}
\cgalParamDefault{`CGAL::Identity_property_map<geom_traits::Point_3>`}
\cgalParamNEnd
\cgalParamNBegin{normal_map}
\cgalParamDescription{a property map associating normals to the elements of the point range}
\cgalParamType{a model of `ReadablePropertyMap` with value type `geom_traits::Vector_3`}
\cgalParamDefault{If this parameter is omitted, normals are not written in the output stream.}
\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{stream_precision}
\cgalParamDescription{a parameter used to set the precision (i.e. how many digits are generated) of the output stream}
\cgalParamType{int}
\cgalParamDefault{the precision of the stream `os`}
\cgalParamExtra{This parameter is only meaningful while using \ascii encoding.}
\cgalParamNEnd
\cgalNamedParamsEnd
\returns `true` if writing was successful, `false` otherwise.
\sa `write_PLY_with_properties()`
*/
template <typename PointRange, typename CGAL_NP_TEMPLATE_PARAMETERS>
bool write_PLY(std::ostream& os,
const PointRange& points,
const CGAL_NP_CLASS& np = parameters::default_values()
#ifndef DOXYGEN_RUNNING
, std::enable_if_t<internal::is_Range<PointRange>::value>* = nullptr
#endif
)
{
using parameters::choose_parameter;
using parameters::get_parameter;
// basic geometric types
typedef Point_set_processing_3_np_helper<PointRange, CGAL_NP_CLASS> NP_helper;
typedef typename NP_helper::Const_point_map PointMap;
typedef typename NP_helper::Normal_map NormalMap;
const bool has_normals = NP_helper::has_normal_map(points, np);
PointMap point_map = NP_helper::get_const_point_map(points, np);
NormalMap normal_map = NP_helper::get_normal_map(points, np);
if(!os)
{
std::cerr << "Error: cannot open file" << std::endl;
return false;
}
set_stream_precision_from_NP(os, np);
if(has_normals)
return write_PLY_with_properties(os, points,
make_ply_point_writer(point_map),
make_ply_normal_writer(normal_map));
return write_PLY_with_properties(os, points, make_ply_point_writer(point_map));
}
/**
\ingroup PkgPointSetProcessing3IOPly
\brief writes the range of `points` (positions + normals, if available) using \ref IOStreamPLY.
\tparam PointRange is a model of `ConstRange`. The value type of
its iterator is the key type of the named parameter `point_map`.
\tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters"
\param filename the path to the output file
\param points input point range
\param np an optional sequence of \ref bgl_namedparameters "Named Parameters" among the ones listed below
\cgalNamedParamsBegin
\cgalParamNBegin{use_binary_mode}
\cgalParamDescription{indicates whether data should be written in binary (`true`) or in \ascii (`false`)}
\cgalParamType{Boolean}
\cgalParamDefault{`true`}
\cgalParamNEnd
\cgalParamNBegin{point_map}
\cgalParamDescription{a property map associating points to the elements of the point range}
\cgalParamType{a model of `ReadablePropertyMap` with value type `geom_traits::Point_3`}
\cgalParamDefault{`CGAL::Identity_property_map<geom_traits::Point_3>`}
\cgalParamNEnd
\cgalParamNBegin{normal_map}
\cgalParamDescription{a property map associating normals to the elements of the point range}
\cgalParamType{a model of `ReadablePropertyMap` with value type `geom_traits::Vector_3`}
\cgalParamDefault{If this parameter is omitted, normals are not written in the output file.}
\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{stream_precision}
\cgalParamDescription{a parameter used to set the precision (i.e. how many digits are generated) of the output stream}
\cgalParamType{int}
\cgalParamDefault{`6`}
\cgalParamExtra{This parameter is only meaningful while using \ascii encoding.}
\cgalParamNEnd
\cgalNamedParamsEnd
\returns `true` if writing was successful, `false` otherwise.
\sa `write_PLY_with_properties()`
*/
template <typename PointRange, typename CGAL_NP_TEMPLATE_PARAMETERS>
bool write_PLY(const std::string& filename,
const PointRange& points,
const CGAL_NP_CLASS& np = parameters::default_values()
#ifndef DOXYGEN_RUNNING
, std::enable_if_t<internal::is_Range<PointRange>::value>* = nullptr
#endif
)
{
const bool binary = CGAL::parameters::choose_parameter(CGAL::parameters::get_parameter(np, internal_np::use_binary_mode), true);
if(binary)
{
std::ofstream os(filename, std::ios::binary);
CGAL::IO::set_mode(os, CGAL::IO::BINARY);
return write_PLY(os, points, np);
}
else
{
std::ofstream os(filename);
CGAL::IO::set_mode(os, CGAL::IO::ASCII);
return write_PLY(os, points, np);
}
}
} // namespace IO
} // namespace CGAL
#endif // CGAL_POINT_SET_PROCESSING_WRITE_PLY_POINTS_H

View File

@ -1,194 +0,0 @@
// Copyright (c) 2007-09 INRIA Sophia-Antipolis (France).
// 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) : Pierre Alliez and Laurent Saboret
#ifndef CGAL_POINT_SET_PROCESSING_WRITE_XYZ_POINTS_H
#define CGAL_POINT_SET_PROCESSING_WRITE_XYZ_POINTS_H
#include <CGAL/license/Point_set_processing_3.h>
#include <CGAL/IO/helpers.h>
#include <CGAL/property_map.h>
#include <CGAL/assertions.h>
#include <CGAL/Kernel_traits.h>
#include <CGAL/Iterator_range.h>
#include <CGAL/Named_function_parameters.h>
#include <CGAL/boost/graph/named_params_helper.h>
#include <iostream>
#include <fstream>
#include <iterator>
#include <type_traits>
namespace CGAL {
namespace Point_set_processing_3 {
namespace internal {
template <typename PointRange, typename CGAL_NP_TEMPLATE_PARAMETERS>
bool write_XYZ_PSP(std::ostream& os,
const PointRange& points,
const CGAL_NP_CLASS& np = CGAL::parameters::default_values())
{
using CGAL::parameters::choose_parameter;
using CGAL::parameters::get_parameter;
// basic geometric types
typedef Point_set_processing_3_np_helper<PointRange, CGAL_NP_CLASS> NP_helper;
typedef typename NP_helper::Const_point_map PointMap;
typedef typename NP_helper::Normal_map NormalMap;
const bool has_normals = NP_helper::has_normal_map(points, np);
PointMap point_map = NP_helper::get_const_point_map(points, np);
NormalMap normal_map = NP_helper::get_normal_map(points, np);
CGAL_precondition(points.begin() != points.end());
if(!os)
{
std::cerr << "Error: cannot open file" << std::endl;
return false;
}
set_stream_precision_from_NP(os, np);
// Write positions + normals
for(typename PointRange::const_iterator it = points.begin(); it != points.end(); it++)
{
os << get(point_map, *it);
if(has_normals)
os << " " << get(normal_map, *it);
os << "\n";
}
os << std::flush;
return !os.fail();
}
} // namespace internal
} // Point_set_processing_3
namespace IO {
/**
\ingroup PkgPointSetProcessing3IOXyz
\brief writes the range of `points` (positions + normals, if available), using the \ref IOStreamXYZ.
\tparam PointRange is a model of `ConstRange`. The value type of
its iterator is the key type of the named parameter `point_map`.
\tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters"
\param os output stream
\param points input point range
\param np an 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 `ReadablePropertyMap` with value type `geom_traits::Point_3`}
\cgalParamDefault{`CGAL::Identity_property_map<geom_traits::Point_3>`}
\cgalParamNEnd
\cgalParamNBegin{normal_map}
\cgalParamDescription{a property map associating normals to the elements of the point range}
\cgalParamType{a model of `ReadablePropertyMap` with value type `geom_traits::Vector_3`}
\cgalParamDefault{If this parameter is omitted, normals are not written in the output stream.}
\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{stream_precision}
\cgalParamDescription{a parameter used to set the precision (i.e. how many digits are generated) of the output stream}
\cgalParamType{int}
\cgalParamDefault{the precision of the stream `os`}
\cgalParamNEnd
\cgalNamedParamsEnd
\returns `true` if writing was successful, `false` otherwise.
*/
template <typename PointRange, typename CGAL_NP_TEMPLATE_PARAMETERS>
bool write_XYZ(std::ostream& os,
const PointRange& points,
const CGAL_NP_CLASS& np = parameters::default_values()
#ifndef DOXYGEN_RUNNING
, std::enable_if_t<internal::is_Range<PointRange>::value>* = nullptr
#endif
)
{
return Point_set_processing_3::internal::write_XYZ_PSP(os, points, np);
}
/**
\ingroup PkgPointSetProcessing3IOXyz
\brief writes the range of `points` (positions + normals, if available), using the \ref IOStreamXYZ.
\tparam PointRange is a model of `ConstRange`. The value type of
its iterator is the key type of the named parameter `point_map`.
\tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters"
\param filename path to the output file
\param points input point range
\param np an 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 `ReadablePropertyMap` with value type `geom_traits::Point_3`}
\cgalParamDefault{`CGAL::Identity_property_map<geom_traits::Point_3>`}
\cgalParamNEnd
\cgalParamNBegin{normal_map}
\cgalParamDescription{a property map associating normals to the elements of the point range}
\cgalParamType{a model of `ReadablePropertyMap` with value type `geom_traits::Vector_3`}
\cgalParamDefault{If this parameter is omitted, normals are not written in the output file.}
\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{stream_precision}
\cgalParamDescription{a parameter used to set the precision (i.e. how many digits are generated) of the output stream}
\cgalParamType{int}
\cgalParamDefault{`6`}
\cgalParamNEnd
\cgalNamedParamsEnd
\returns `true` if writing was successful, `false` otherwise.
*/
template <typename PointRange, typename CGAL_NP_TEMPLATE_PARAMETERS>
bool write_XYZ(const std::string& filename,
const PointRange& points,
const CGAL_NP_CLASS& np = parameters::default_values()
#ifndef DOXYGEN_RUNNING
, std::enable_if_t<internal::is_Range<PointRange>::value>* = nullptr
#endif
)
{
std::ofstream os(filename);
return write_XYZ(os, points, np);
}
} // namespace IO
} // namespace CGAL
#endif // CGAL_POINT_SET_PROCESSING_WRITE_XYZ_POINTS_H

View File

@ -5,8 +5,8 @@
#include <CGAL/Shape_detection/Region_growing/Point_set.h>
#include <CGAL/IO/read_xyz_points.h>
#include <CGAL/IO/write_ply_points.h>
#include <CGAL/IO/XYZ.h>
#include <CGAL/IO/PLY.h>
#include <CGAL/Real_timer.h>

View File

@ -61,7 +61,7 @@ The following table lists some \cgal data structures that have I/O functions com
</tr>
<tr>
<td>Any point range</td>
<td>\link PkgPointSetProcessing3IOOff CGAL::IO::read_OFF(const std::string&, PointOutputIterator)\endlink</td>
<td>\link PkgStreamSupportIoFuncsOFF CGAL::IO::read_OFF(const std::string&, PointOutputIterator)\endlink</td>
</tr>
<tr>
<td>Polygon Soup</td>
@ -89,7 +89,7 @@ The following table lists some \cgal data structures that have I/O functions com
</tr>
<tr>
<td>Any point range</td>
<td>\link PkgPointSetProcessing3IOOff CGAL::IO::write_OFF(const std::string&, const PointRange&)\endlink</td>
<td>\link PkgStreamSupportIoFuncsOFF CGAL::IO::write_OFF(const std::string&, const PointRange&)\endlink</td>
</tr>
<tr>
<td>Polygon Soup</td>
@ -239,7 +239,7 @@ A precise specification of those formats is available <a href="https://paulbourk
</tr>
<tr>
<td>Any point range</td>
<td>\link PkgPointSetProcessing3IOPly CGAL::IO::read_PLY(const std::string&, PointRange&)\endlink</td>
<td>\link PkgStreamSupportIoFuncsPLY CGAL::IO::read_PLY(const std::string&, PointRange&)\endlink</td>
</tr>
<tr>
<td>Polygon Soup</td>
@ -263,7 +263,7 @@ A precise specification of those formats is available <a href="https://paulbourk
</tr>
<tr>
<td>Any point range</td>
<td>\link PkgPointSetProcessing3IOPly CGAL::IO::write_PLY(const std::string&, const PointRange&)\endlink</td>
<td>\link PkgStreamSupportIoFuncsPLY CGAL::IO::write_PLY(const std::string&, const PointRange&)\endlink</td>
</tr>
<tr>
<td>Polygon Soup</td>
@ -298,7 +298,7 @@ A precise specification of those formats is available
</tr>
<tr>
<td>Any point range</td>
<td>\link PkgPointSetProcessing3IOLas CGAL::IO::read_LAS(const std::string&, PointRange&)\endlink</td>
<td>\link PkgStreamSupportIoFuncsLAS CGAL::IO::read_LAS(const std::string&, PointRange&)\endlink</td>
</tr>
<tr>
<td rowspan="2">Output</td>
@ -308,7 +308,7 @@ A precise specification of those formats is available
</tr>
<tr>
<td>Any point range</td>
<td>\link PkgPointSetProcessing3IOLas CGAL::IO::write_LAS(const std::string&, const PointRange&)\endlink</td>
<td>\link PkgStreamSupportIoFuncsLAS CGAL::IO::write_LAS(const std::string&, const PointRange&)\endlink</td>
</tr>
</table>
@ -331,7 +331,7 @@ of its coordinates and other properties. Only coordinates and normals are curren
</tr>
<tr>
<td>Any point range</td>
<td>\link PkgPointSetProcessing3IOXyz CGAL::IO::read_XYZ(const std::string&, PointRange&)\endlink</td>
<td>\link PkgStreamSupportIoFuncsXYZ CGAL::IO::read_XYZ(const std::string&, PointRange&)\endlink</td>
</tr>
<tr>
<td rowspan="2">Output</td>
@ -341,7 +341,7 @@ of its coordinates and other properties. Only coordinates and normals are curren
</tr>
<tr>
<td>Any point range</td>
<td>\link PkgPointSetProcessing3IOXyz CGAL::IO::write_XYZ(const std::string&, const PointRange&)\endlink</td>
<td>\link PkgStreamSupportIoFuncsXYZ CGAL::IO::write_XYZ(const std::string&, const PointRange&)\endlink</td>
</tr>
</table>

View File

@ -306,23 +306,23 @@ The following table shows which file formats can be read from and written for po
</tr>
<tr>
<th>\ref IOStreamOFF "OFF"</th>
<td>\link PkgPointSetProcessing3IOOff `CGAL::IO::read_OFF()` \endlink</td>
<td>\link PkgPointSetProcessing3IOOff `CGAL::IO::write_OFF()` \endlink</td>
<td>\link PkgStreamSupportIoFuncsOFF `CGAL::IO::read_OFF()` \endlink</td>
<td>\link PkgStreamSupportIoFuncsOFF `CGAL::IO::write_OFF()` \endlink</td>
</tr>
<tr>
<th>\ref IOStreamXYZ "XYZ"</th>
<td>\link PkgPointSetProcessing3IOXyz `CGAL::IO::read_XYZ()` \endlink</td>
<td>\link PkgPointSetProcessing3IOXyz `CGAL::IO::write_XYZ()` \endlink</td>
<td>\link PkgStreamSupportIoFuncsXYZ `CGAL::IO::read_XYZ()` \endlink</td>
<td>\link PkgStreamSupportIoFuncsXYZ `CGAL::IO::write_XYZ()` \endlink</td>
</tr>
<tr>
<th>\ref IOStreamPLY "PLY"</th>
<td>\link PkgPointSetProcessing3IOPly `CGAL::IO::read_PLY()` \endlink</td>
<td>\link PkgPointSetProcessing3IOPly `CGAL::IO::write_PLY()` \endlink</td>
<td>\link PkgStreamSupportIoFuncsPLY `CGAL::IO::read_PLY()` \endlink</td>
<td>\link PkgStreamSupportIoFuncsPLY `CGAL::IO::write_PLY()` \endlink</td>
</tr>
<tr>
<th>\ref IOStreamLAS "LAS"</th>
<td>\link PkgPointSetProcessing3IOLas `CGAL::IO::read_LAS()` \endlink</td>
<td>\link PkgPointSetProcessing3IOLas `CGAL::IO::write_LAS()` \endlink</td>
<td>\link PkgStreamSupportIoFuncsLAS `CGAL::IO::read_LAS()` \endlink</td>
<td>\link PkgStreamSupportIoFuncsLAS `CGAL::IO::write_LAS()` \endlink</td>
</tr>
</table>

View File

@ -36,6 +36,14 @@
/// I/O Functions for the \ref IOStream3MF
/// \ingroup IOstreamFunctions
/// \defgroup PkgStreamSupportIoFuncsLAS LAS I/O Functions
/// I/O Functions for the \ref IOStreamLAS
/// \ingroup IOstreamFunctions
/// \defgroup PkgStreamSupportIoFuncsXYZ XYZ I/O Functions
/// I/O Functions for the \ref IOStreamXYZ
/// \ingroup IOstreamFunctions
/// \defgroup PkgStreamSupportEnumRef I/O Enums
/// \ingroup PkgStreamSupportRef
@ -99,5 +107,7 @@ the printing mode.
- \link PkgStreamSupportIoFuncsVTK I/O for VTK files \endlink
- \link PkgStreamSupportIoFuncs3MF I/O for 3MF files \endlink
- \link PkgStreamSupportIoFuncsWKT I/O for WKT files \endlink
- \link PkgStreamSupportIoFuncsLAS I/O for LAS files \endlink
- \link PkgStreamSupportIoFuncsXYZ I/O for XYZ files \endlink
*/

View File

@ -0,0 +1,357 @@
// Copyright (c) 2017 GeometryFactory
//
// This file is part of CGAL (www.cgal.org);
//
// $URL$
// $Id$
// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial
//
// Author(s) : Simon Giraudot
#ifndef CGAL_IO_LAS_H
#define CGAL_IO_LAS_H
#include <fstream>
#include <iostream>
#include <vector>
#include <type_traits>
#include <CGAL/IO/LAS/Las_property.h>
#include <CGAL/IO/helpers.h>
#include <CGAL/Named_function_parameters.h>
#include <CGAL/boost/graph/named_params_helper.h>
#include <CGAL/Kernel_traits.h>
namespace CGAL {
////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////
// Read
namespace IO {
/**
\ingroup PkgStreamSupportIoFuncsLAS
generates a %LAS property handler to read 3D points. Points are
constructed from the input the using 3 %LAS properties
`LAS_property::X`, `LAS_property::Y` and `LAS_property::Z`.
\tparam PointMap the property map used to store points.
\sa `read_LAS_with_properties()`
\sa \ref IOStreamLAS
*/
template <typename PointMap>
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);
/**
\ingroup PkgStreamSupportIoFuncsLAS
\brief reads user-selected points properties from a .las or .laz stream.
Potential additional properties are ignored.
Properties are handled through a variadic list of property
handlers. A `PropertyHandler` can either be:
- A `std::pair<PropertyMap, LAS_property::Tag >` if the user wants to
read a %LAS property as a scalar value `LAS_property::Tag::type` (for
example, storing an `int` %LAS property into an `int` variable).
- A `std::tuple<PropertyMap, Constructor,
LAS_property::Tag...>` if the user wants to use one or several
%LAS properties to construct a complex object (for example,
storing 4 `unsigned short` %LAS properties into a %Color object
that can for example be a `std::array<unsigned short,
4>`). In that case, the second element of the tuple should be a
functor that constructs the value type of `PropertyMap` from N
objects of of type `LAS_property::Tag::type`.
The %LAS standard defines a fixed set of properties accessible
through the following tag classes:
- `LAS_property::X` with type `double`
- `LAS_property::Y` with type `double`
- `LAS_property::Z` with type `double`
- `LAS_property::Intensity` with type `unsigned short`
- `LAS_property::Return_number` with type `unsigned char`
- `LAS_property::Number_of_returns` with type `unsigned char`
- `LAS_property::Scan_direction_flag` with type `unsigned char`
- `LAS_property::Edge_of_flight_line` with type `unsigned char`
- `LAS_property::Classification` with type `unsigned char`
- `LAS_property::Synthetic_flag` with type `unsigned char`
- `LAS_property::Keypoint_flag` with type `unsigned char`
- `LAS_property::Withheld_flag` with type `unsigned char`
- `LAS_property::Scan_angle` with type `double`
- `LAS_property::User_data` with type `unsigned char`
- `LAS_property::Point_source_ID` with type `unsigned short`
- `LAS_property::Deleted_flag` with type `unsigned int`
- `LAS_property::GPS_time` with type `double`
- `LAS_property::R` with type `unsigned short`
- `LAS_property::G` with type `unsigned short`
- `LAS_property::B` with type `unsigned short`
- `LAS_property::I` with type `unsigned short`
\attention To read a binary file, the flag `std::ios::binary` must be set during the creation of the `ifstream`.
\tparam OutputIteratorValueType type of objects that can be put in `PointOutputIterator`.
It must be a model of `DefaultConstructible` and defaults to `value_type_traits<PointOutputIterator>::%type`.
It can be omitted if the default is fine.
\tparam PointOutputIterator iterator over output points.
\tparam PropertyHandler handlers to recover properties.
\returns `true` if reading was successful, `false` otherwise.
\sa `make_las_point_reader()`
\sa \ref IOStreamLAS
*/
template <typename OutputIteratorValueType,
typename PointOutputIterator,
typename ... PropertyHandler>
bool read_LAS_with_properties(std::istream& is,
PointOutputIterator output,
PropertyHandler&& ... properties);
/**
\ingroup PkgStreamSupportIoFuncsLAS
\brief reads points (position only) using the \ref IOStreamLAS.
Potential additional properties are ignored.
\attention To read a binary file, the flag `std::ios::binary` must be set during the creation of the `ifstream`.
\tparam OutputIteratorValueType type of objects that can be put in `PointOutputIterator`.
It must be a model of `DefaultConstructible` and defaults to `value_type_traits<PointOutputIterator>::%type`.
It 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 is input stream
\param output output iterator over points
\param np an 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<geom_traits::Point_3>`}
\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
\cgalNamedParamsEnd
\returns `true` if reading was successful, `false` otherwise.
\sa `read_LAS_with_properties()`
*/
template <typename OutputIteratorValueType,
typename PointOutputIterator,
typename CGAL_NP_TEMPLATE_PARAMETERS>
bool read_LAS(std::istream& is,
PointOutputIterator output,
const CGAL_NP_CLASS& np = parameters::default_values());
/**
\ingroup PkgStreamSupportIoFuncsLAS
\brief reads points (position only) using the \ref IOStreamLAS.
Potential additional properties are ignored.
\tparam OutputIteratorValueType type of objects that can be put in `PointOutputIterator`.
It must be a model of `DefaultConstructible` and defaults to `value_type_traits<PointOutputIterator>::%type`.
It 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 filename name of the input file
\param output output iterator over points
\param np an 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<geom_traits::Point_3>`}
\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
\cgalNamedParamsEnd
\returns `true` if reading was successful, `false` otherwise.
\sa `read_LAS_with_properties()`
*/
template <typename OutputIteratorValueType,
typename PointOutputIterator,
typename CGAL_NP_TEMPLATE_PARAMETERS>
bool read_LAS(const std::string& filename,
PointOutputIterator output,
const CGAL_NP_CLASS& np = parameters::default_values());
/**
\ingroup PkgStreamSupportIoFuncsLAS
\brief generates a %LAS property handler to write 3D points.
\tparam PointMap the property map used to store points.
\sa `write_LAS()`
\sa \ref IOStreamLAS
*/
template <typename PointMap>
std::tuple<PointMap, LAS_property::X, LAS_property::Y, LAS_property::Z >
make_las_point_writer(PointMap point_map);
/**
\ingroup PkgStreamSupportIoFuncsLAS
\brief writes the range of `points` with properties to a .las stream.
Properties are handled through a variadic list of property
handlers. A `PropertyHandle` is a `std::pair<PropertyMap,
LAS_property::Tag >` used to write a scalar value
`LAS_property::Tag::type` as a %LAS property (for example,
writing an `int` variable as an `int` %LAS property). An exception
is used for points that are written using a `std::tuple` object.
See documentation of `read_LAS_with_properties()` for the
list of available `LAS_property::Tag` classes.
\attention To write to a binary file, the flag `std::ios::binary` must be set during the creation of the `ofstream`.
\tparam PointRange is a model of `ConstRange`. The value type of
its iterator is the key type of the named parameter `point_map`.
\tparam PointMap is a model of `ReadablePropertyMap` with a value_type = `CGAL::Point_3`.
\tparam PropertyHandler handlers to recover properties.
\returns `true` if writing was successful, `false` otherwise.
\sa `make_las_point_writer()`
\sa \ref IOStreamLAS
*/
template <typename PointRange,
typename PointMap,
typename ... PropertyHandler>
bool write_LAS_with_properties(std::ostream& os, ///< output stream.
const PointRange& points, ///< input point range.
std::tuple<PointMap,
LAS_property::X,
LAS_property::Y,
LAS_property::Z> point_property, ///< property handler for points
PropertyHandler&& ... properties ///< parameter pack of property handlers
);
/**
\ingroup PkgStreamSupportIoFuncsLAS
\brief writes the range of `points` (positions only), using the \ref IOStreamLAS.
\attention To write to a binary file, the flag `std::ios::binary` must be set during the creation of the `ofstream`.
\tparam PointRange is a model of `ConstRange`. The value type of
its iterator is the key type of the named parameter `point_map`.
\tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters"
\param os output stream
\param points input point range
\param np an 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 `ReadablePropertyMap` with value type `geom_traits::Point_3`}
\cgalParamDefault{`CGAL::Identity_property_map<geom_traits::Point_3>`}
\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
\cgalNamedParamsEnd
\returns `true` if writing was successful, `false` otherwise.
\sa \ref IOStreamLAS
\sa `write_LAS_with_properties()`
*/
template <typename PointRange, typename CGAL_NP_TEMPLATE_PARAMETERS>
bool write_LAS(std::ostream& os,
const PointRange& points,
const CGAL_NP_CLASS& np = parameters::default_values()
#ifndef DOXYGEN_RUNNING
, std::enable_if_t<internal::is_Range<PointRange>::value>* = nullptr
#endif
);
/**
\ingroup PkgStreamSupportIoFuncsLAS
writes the range of `points` (positions only), using the \ref IOStreamLAS.
\tparam PointRange is a model of `ConstRange`. The value type of
its iterator is the key type of the named parameter `point_map`.
\tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters"
\param filename the path the output file
\param points input point range
\param np an 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 `ReadablePropertyMap` with value type `geom_traits::Point_3`}
\cgalParamDefault{`CGAL::Identity_property_map<geom_traits::Point_3>`}
\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
\cgalNamedParamsEnd
\returns `true` if writing was successful, `false` otherwise.
\sa `write_LAS_with_properties()`
*/
template <typename PointRange, typename CGAL_NP_TEMPLATE_PARAMETERS>
bool write_LAS(const std::string& filename,
const PointRange& points,
const CGAL_NP_CLASS& np = parameters::default_values()
#ifndef DOXYGEN_RUNNING
, std::enable_if_t<internal::is_Range<PointRange>::value>* = nullptr
#endif
);
} // namespace IO
} // namespace CGAL
#include <CGAL/IO/LAS/read_las_points.h>
#include <CGAL/IO/LAS/write_las_points.h>
#endif // CGAL_IO_LAS_H

View File

@ -0,0 +1,94 @@
// Copyright (c) 2017 GeometryFactory
//
// This file is part of CGAL (www.cgal.org);
//
// $URL$
// $Id$
// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial
//
// Author(s) : Simon Giraudot
#ifndef CGAL_IO_LAS_LAS_PROPERTY_H
#define CGAL_IO_LAS_LAS_PROPERTY_H
#include <tuple>
#include <CGAL/Kernel_traits.h>
namespace CGAL {
namespace IO {
namespace LAS_property {
namespace Id {
enum Id
{
X,
Y,
Z,
Intensity,
Return_number,
Number_of_returns,
Scan_direction_flag,
Edge_of_flight_line,
Classification,
Synthetic_flag,
Keypoint_flag,
Withheld_flag,
Scan_angle,
User_data,
Point_source_ID,
Deleted_flag,
GPS_time,
R,
G,
B,
I
};
} // namespace Id
template <typename T, Id::Id id>
struct Base
{
typedef T type;
};
typedef Base<double, Id::X> X;
typedef Base<double, Id::Y> Y;
typedef Base<double, Id::Z> Z;
typedef Base<unsigned short, Id::Intensity> Intensity;
typedef Base<unsigned char, Id::Return_number> Return_number;
typedef Base<unsigned char, Id::Number_of_returns> Number_of_returns;
typedef Base<unsigned char, Id::Scan_direction_flag> Scan_direction_flag;
typedef Base<unsigned char, Id::Edge_of_flight_line> Edge_of_flight_line;
typedef Base<unsigned char, Id::Classification> Classification;
typedef Base<unsigned char, Id::Synthetic_flag> Synthetic_flag;
typedef Base<unsigned char, Id::Keypoint_flag> Keypoint_flag;
typedef Base<unsigned char, Id::Withheld_flag> Withheld_flag;
typedef Base<float, Id::Scan_angle> Scan_angle;
typedef Base<unsigned char, Id::User_data> User_data;
typedef Base<unsigned short, Id::Point_source_ID> Point_source_ID;
typedef Base<unsigned int, Id::Deleted_flag> Deleted_flag;
typedef Base<double, Id::GPS_time> GPS_time;
typedef Base<unsigned short, Id::R> R;
typedef Base<unsigned short, Id::G> G;
typedef Base<unsigned short, Id::B> B;
typedef Base<unsigned short, Id::I> I;
} // namespace LAS_property
// documenation in ../LAS.h
template <typename PointMap>
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)
{
return std::make_tuple (point_map, typename Kernel_traits<typename PointMap::value_type>::Kernel::Construct_point_3(),
LAS_property::X(), LAS_property::Y(), LAS_property::Z());
}
} // namespace IO
} // namespace CGAL
#endif

View File

@ -1,21 +1,22 @@
// Copyright (c) 2017 GeometryFactory
// All rights reserved.
//
// This file is part of CGAL (www.cgal.org).
// This file is part of CGAL (www.cgal.org);
//
// $URL$
// $Id$
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial
// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial
//
// Author(s) : Simon Giraudot
#ifndef CGAL_POINT_SET_PROCESSING_READ_LAS_POINTS_H
#define CGAL_POINT_SET_PROCESSING_READ_LAS_POINTS_H
#ifndef CGAL_IO_LAS_READ_LAS_POINTS_H
#define CGAL_IO_LAS_READ_LAS_POINTS_H
#include <CGAL/license/Point_set_processing_3.h>
#ifdef CGAL_LINKED_WITH_LASLIB
#include <CGAL/config.h>
#include <CGAL/IO/LAS/Las_property.h>
#include <CGAL/IO/LAS.h>
#include <CGAL/property_map.h>
#include <CGAL/value_type_traits.h>
#include <CGAL/Kernel_traits.h>
@ -59,89 +60,6 @@ namespace CGAL {
namespace IO {
/// \cond SKIP_IN_MANUAL
namespace LAS_property {
namespace Id {
enum Id
{
X,
Y,
Z,
Intensity,
Return_number,
Number_of_returns,
Scan_direction_flag,
Edge_of_flight_line,
Classification,
Synthetic_flag,
Keypoint_flag,
Withheld_flag,
Scan_angle,
User_data,
Point_source_ID,
Deleted_flag,
GPS_time,
R,
G,
B,
I
};
} // namespace Id
template <typename T, Id::Id id>
struct Base
{
typedef T type;
};
typedef Base<double, Id::X> X;
typedef Base<double, Id::Y> Y;
typedef Base<double, Id::Z> Z;
typedef Base<unsigned short, Id::Intensity> Intensity;
typedef Base<unsigned char, Id::Return_number> Return_number;
typedef Base<unsigned char, Id::Number_of_returns> Number_of_returns;
typedef Base<unsigned char, Id::Scan_direction_flag> Scan_direction_flag;
typedef Base<unsigned char, Id::Edge_of_flight_line> Edge_of_flight_line;
typedef Base<unsigned char, Id::Classification> Classification;
typedef Base<unsigned char, Id::Synthetic_flag> Synthetic_flag;
typedef Base<unsigned char, Id::Keypoint_flag> Keypoint_flag;
typedef Base<unsigned char, Id::Withheld_flag> Withheld_flag;
typedef Base<float, Id::Scan_angle> Scan_angle;
typedef Base<unsigned char, Id::User_data> User_data;
typedef Base<unsigned short, Id::Point_source_ID> Point_source_ID;
typedef Base<unsigned int, Id::Deleted_flag> Deleted_flag;
typedef Base<double, Id::GPS_time> GPS_time;
typedef Base<unsigned short, Id::R> R;
typedef Base<unsigned short, Id::G> G;
typedef Base<unsigned short, Id::B> B;
typedef Base<unsigned short, Id::I> I;
}
/// \endcond
/**
\ingroup PkgPointSetProcessing3IOLas
generates a %LAS property handler to read 3D points. Points are
constructed from the input the using 3 %LAS properties
`LAS_property::X`, `LAS_property::Y` and `LAS_property::Z`.
\tparam PointMap the property map used to store points.
\sa `read_LAS_with_properties()`
\sa \ref IOStreamLAS
*/
template <typename PointMap>
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)
{
return std::make_tuple (point_map, typename Kernel_traits<typename PointMap::value_type>::Kernel::Construct_point_3(),
LAS_property::X(), LAS_property::Y(), LAS_property::Z());
}
/// \cond SKIP_IN_MANUAL
namespace internal {
@ -309,69 +227,10 @@ void process_properties (const LASpoint& reader, OutputValueType& new_element,
} // namespace LAS
} // namespace internal
/// \endcond
/**
\ingroup PkgPointSetProcessing3IOLas
\brief reads user-selected points properties from a .las or .laz stream.
Potential additional properties are ignored.
Properties are handled through a variadic list of property
handlers. A `PropertyHandler` can either be:
- A `std::pair<PropertyMap, LAS_property::Tag >` if the user wants to
read a %LAS property as a scalar value `LAS_property::Tag::type` (for
example, storing an `int` %LAS property into an `int` variable).
- A `std::tuple<PropertyMap, Constructor,
LAS_property::Tag...>` if the user wants to use one or several
%LAS properties to construct a complex object (for example,
storing 4 `unsigned short` %LAS properties into a %Color object
that can for example be a `std::array<unsigned short,
4>`). In that case, the second element of the tuple should be a
functor that constructs the value type of `PropertyMap` from N
objects of of type `LAS_property::Tag::type`.
The %LAS standard defines a fixed set of properties accessible
through the following tag classes:
- `LAS_property::X` with type `double`
- `LAS_property::Y` with type `double`
- `LAS_property::Z` with type `double`
- `LAS_property::Intensity` with type `unsigned short`
- `LAS_property::Return_number` with type `unsigned char`
- `LAS_property::Number_of_returns` with type `unsigned char`
- `LAS_property::Scan_direction_flag` with type `unsigned char`
- `LAS_property::Edge_of_flight_line` with type `unsigned char`
- `LAS_property::Classification` with type `unsigned char`
- `LAS_property::Synthetic_flag` with type `unsigned char`
- `LAS_property::Keypoint_flag` with type `unsigned char`
- `LAS_property::Withheld_flag` with type `unsigned char`
- `LAS_property::Scan_angle` with type `double`
- `LAS_property::User_data` with type `unsigned char`
- `LAS_property::Point_source_ID` with type `unsigned short`
- `LAS_property::Deleted_flag` with type `unsigned int`
- `LAS_property::GPS_time` with type `double`
- `LAS_property::R` with type `unsigned short`
- `LAS_property::G` with type `unsigned short`
- `LAS_property::B` with type `unsigned short`
- `LAS_property::I` with type `unsigned short`
\attention To read a binary file, the flag `std::ios::binary` must be set during the creation of the `ifstream`.
\tparam OutputIteratorValueType type of objects that can be put in `PointOutputIterator`.
It must be a model of `DefaultConstructible` and defaults to `value_type_traits<PointOutputIterator>::%type`.
It can be omitted if the default is fine.
\tparam PointOutputIterator iterator over output points.
\tparam PropertyHandler handlers to recover properties.
\returns `true` if reading was successful, `false` otherwise.
\sa `make_las_point_reader()`
\sa \ref IOStreamLAS
*/
// documenation in ../LAS.h
template <typename OutputIteratorValueType,
typename PointOutputIterator,
typename ... PropertyHandler>
@ -420,49 +279,13 @@ bool read_LAS_with_properties(std::istream& is,
/// \endcond
/**
\ingroup PkgPointSetProcessing3IOLas
\brief reads points (position only) using the \ref IOStreamLAS.
Potential additional properties are ignored.
\attention To read a binary file, the flag `std::ios::binary` must be set during the creation of the `ifstream`.
\tparam OutputIteratorValueType type of objects that can be put in `PointOutputIterator`.
It must be a model of `DefaultConstructible` and defaults to `value_type_traits<PointOutputIterator>::%type`.
It 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 is input stream
\param output output iterator over points
\param np an 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<geom_traits::Point_3>`}
\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
\cgalNamedParamsEnd
\returns `true` if reading was successful, `false` otherwise.
\sa `read_LAS_with_properties()`
*/
// documenation in ../LAS.h
template <typename OutputIteratorValueType,
typename PointOutputIterator,
typename CGAL_NP_TEMPLATE_PARAMETERS>
typename CGAL_NP_TEMPLATE_PARAMETERS_NO_DEFAULT>
bool read_LAS(std::istream& is,
PointOutputIterator output,
const CGAL_NP_CLASS& np = parameters::default_values())
const CGAL_NP_CLASS& np)
{
using parameters::choose_parameter;
using parameters::get_parameter;
@ -486,47 +309,13 @@ bool read_LAS(std::istream& is, OutputIterator output, const CGAL_NP_CLASS& np =
/// \endcond
/**
\ingroup PkgPointSetProcessing3IOLas
\brief reads points (position only) using the \ref IOStreamLAS.
Potential additional properties are ignored.
\tparam OutputIteratorValueType type of objects that can be put in `PointOutputIterator`.
It must be a model of `DefaultConstructible` and defaults to `value_type_traits<PointOutputIterator>::%type`.
It 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 filename name of the input file
\param output output iterator over points
\param np an 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<geom_traits::Point_3>`}
\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
\cgalNamedParamsEnd
\returns `true` if reading was successful, `false` otherwise.
\sa `read_LAS_with_properties()`
*/
// documentation in ../LAS.h
template <typename OutputIteratorValueType,
typename PointOutputIterator,
typename CGAL_NP_TEMPLATE_PARAMETERS>
typename CGAL_NP_TEMPLATE_PARAMETERS_NO_DEFAULT>
bool read_LAS(const std::string& filename,
PointOutputIterator output,
const CGAL_NP_CLASS& np = parameters::default_values())
const CGAL_NP_CLASS& np)
{
std::ifstream is(filename, std::ios::binary);
CGAL::IO::set_mode(is, CGAL::IO::BINARY);
@ -549,4 +338,5 @@ bool read_LAS(const std::string& fname, OutputIterator output, const CGAL_NP_CLA
} // namespace CGAL
#endif // CGAL_POINT_SET_PROCESSING_READ_LAS_POINTS_H
#endif // CGAL_LINKED_WITH_LASLIB
#endif // CGAL_IO_LAS_READ_LAS_POINTS_H

View File

@ -1,21 +1,21 @@
// Copyright (c) 2017 GeometryFactory
// All rights reserved.
//
// This file is part of CGAL (www.cgal.org).
// This file is part of CGAL (www.cgal.org);
//
// $URL$
// $Id$
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial
// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial
//
// Author(s) : Simon Giraudot
#ifndef CGAL_POINT_SET_PROCESSING_WRITE_LAS_POINTS_H
#define CGAL_POINT_SET_PROCESSING_WRITE_LAS_POINTS_H
#ifndef CGAL_IO_LAS_WRITE_LAS_POINTS_H
#define CGAL_IO_LAS_WRITE_LAS_POINTS_H
#include <CGAL/license/Point_set_processing_3.h>
#ifdef CGAL_LINKED_WITH_LASLIB
#include <CGAL/IO/helpers.h>
#include <CGAL/IO/LAS/Las_property.h>
#include <CGAL/IO/LAS.h>
#include <CGAL/Bbox_3.h>
#include <CGAL/Named_function_parameters.h>
#include <CGAL/boost/graph/named_params_helper.h>
@ -62,16 +62,7 @@ namespace CGAL {
namespace IO {
/**
\ingroup PkgPointSetProcessing3IOLas
\brief generates a %LAS property handler to write 3D points.
\tparam PointMap the property map used to store points.
\sa `write_LAS()`
\sa \ref IOStreamLAS
*/
// documented in ../LAS.h
template <typename PointMap>
std::tuple<PointMap, LAS_property::X, LAS_property::Y, LAS_property::Z >
make_las_point_writer(PointMap point_map)
@ -192,33 +183,7 @@ namespace LAS {
/// \endcond
/**
\ingroup PkgPointSetProcessing3IOLas
\brief writes the range of `points` with properties to a .las stream.
Properties are handled through a variadic list of property
handlers. A `PropertyHandle` is a `std::pair<PropertyMap,
LAS_property::Tag >` used to write a scalar value
`LAS_property::Tag::type` as a %LAS property (for example,
writing an `int` variable as an `int` %LAS property). An exception
is used for points that are written using a `std::tuple` object.
See documentation of `read_LAS_with_properties()` for the
list of available `LAS_property::Tag` classes.
\attention To write to a binary file, the flag `std::ios::binary` must be set during the creation of the `ofstream`.
\tparam PointRange is a model of `ConstRange`. The value type of
its iterator is the key type of the named parameter `point_map`.
\tparam PointMap is a model of `ReadablePropertyMap` with a value_type = `CGAL::Point_3`.
\tparam PropertyHandler handlers to recover properties.
\returns `true` if writing was successful, `false` otherwise.
\sa `make_las_point_writer()`
\sa \ref IOStreamLAS
*/
// documented in ../LAS.h
template <typename PointRange,
typename PointMap,
typename ... PropertyHandler>
@ -280,47 +245,12 @@ bool write_LAS_with_properties(std::ostream& os, ///< output stream.
return !os.fail();
}
/**
\ingroup PkgPointSetProcessing3IOLas
\brief writes the range of `points` (positions only), using the \ref IOStreamLAS.
\attention To write to a binary file, the flag `std::ios::binary` must be set during the creation of the `ofstream`.
\tparam PointRange is a model of `ConstRange`. The value type of
its iterator is the key type of the named parameter `point_map`.
\tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters"
\param os output stream
\param points input point range
\param np an 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 `ReadablePropertyMap` with value type `geom_traits::Point_3`}
\cgalParamDefault{`CGAL::Identity_property_map<geom_traits::Point_3>`}
\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
\cgalNamedParamsEnd
\returns `true` if writing was successful, `false` otherwise.
\sa \ref IOStreamLAS
\sa `write_LAS_with_properties()`
*/
template <typename PointRange, typename CGAL_NP_TEMPLATE_PARAMETERS>
// documented in ../LAS.h
template <typename PointRange, typename CGAL_NP_TEMPLATE_PARAMETERS_NO_DEFAULT>
bool write_LAS(std::ostream& os,
const PointRange& points,
const CGAL_NP_CLASS& np = parameters::default_values()
#ifndef DOXYGEN_RUNNING
, std::enable_if_t<internal::is_Range<PointRange>::value>* = nullptr
#endif
const CGAL_NP_CLASS& np,
std::enable_if_t<internal::is_Range<PointRange>::value>*
)
{
using parameters::choose_parameter;
@ -338,44 +268,12 @@ bool write_LAS(std::ostream& os,
return write_LAS_with_properties(os, points, make_las_point_writer(point_map));
}
/**
\ingroup PkgPointSetProcessing3IOLas
writes the range of `points` (positions only), using the \ref IOStreamLAS.
\tparam PointRange is a model of `ConstRange`. The value type of
its iterator is the key type of the named parameter `point_map`.
\tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters"
\param filename the path the output file
\param points input point range
\param np an 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 `ReadablePropertyMap` with value type `geom_traits::Point_3`}
\cgalParamDefault{`CGAL::Identity_property_map<geom_traits::Point_3>`}
\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
\cgalNamedParamsEnd
\returns `true` if writing was successful, `false` otherwise.
\sa `write_LAS_with_properties()`
*/
template <typename PointRange, typename CGAL_NP_TEMPLATE_PARAMETERS>
// documented in ../LAS.h
template <typename PointRange, typename CGAL_NP_TEMPLATE_PARAMETERS_NO_DEFAULT>
bool write_LAS(const std::string& filename,
const PointRange& points,
const CGAL_NP_CLASS& np = parameters::default_values()
#ifndef DOXYGEN_RUNNING
, std::enable_if_t<internal::is_Range<PointRange>::value>* = nullptr
#endif
const CGAL_NP_CLASS& np,
std::enable_if_t<internal::is_Range<PointRange>::value>*
)
{
std::ofstream os(filename, std::ios::binary);
@ -387,4 +285,5 @@ bool write_LAS(const std::string& filename,
} // namespace CGAL
#endif // CGAL_POINT_SET_PROCESSING_WRITE_LAS_POINTS_H
#endif // CGAL_LINKED_WITH_LASLIB
#endif // CGAL_IO_LAS_WRITE_LAS_POINTS_H

View File

@ -344,6 +344,213 @@ bool write_OFF(const std::string& fname,
return writer(points, polygons, np);
}
/**
\ingroup PkgStreamSupportIoFuncsOFF
\brief reads points (positions + normals, if available), using the \ref IOStreamOFF.
\tparam OutputIteratorValueType type of objects that can be put in `PointOutputIterator`.
It must be a model of `DefaultConstructible` and defaults to `value_type_traits<PointOutputIterator>::%type`.
It 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 is input stream
\param output output iterator over points
\param np an 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<geom_traits::Point_3>`}
\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
\cgalNamedParamsEnd
\returns `true` if reading was successful, `false` otherwise.
\sa \ref IOStreamOFF
*/
template <typename OutputIteratorValueType,
typename PointOutputIterator,
typename CGAL_NP_TEMPLATE_PARAMETERS>
bool read_OFF(std::istream& is,
PointOutputIterator output,
const CGAL_NP_CLASS& np = parameters::default_values()
#ifndef DOXYGEN_RUNNING
, std::enable_if_t<CGAL::is_iterator<PointOutputIterator>::value>* = nullptr
#endif
);
/**
\ingroup PkgStreamSupportIoFuncsOFF
\brief reads points (positions + normals, if available), using the \ref IOStreamOFF.
\tparam OutputIteratorValueType type of objects that can be put in `PointOutputIterator`.
It must be a model of `DefaultConstructible` and defaults to `value_type_traits<PointOutputIterator>::%type`.
It 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 input file name
\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<geom_traits::Point_3>`}
\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
\cgalNamedParamsEnd
\returns `true` if reading was successful, `false` otherwise.
\sa \ref IOStreamOFF
*/
template <typename OutputIteratorValueType,
typename PointOutputIterator,
typename CGAL_NP_TEMPLATE_PARAMETERS>
bool read_OFF(const std::string& fname,
PointOutputIterator output,
const CGAL_NP_CLASS& np = parameters::default_values()
#ifndef DOXYGEN_RUNNING
, std::enable_if_t<CGAL::is_iterator<PointOutputIterator>::value>* = nullptr
#endif
);
/**
\ingroup PkgStreamSupportIoFuncsOFF
\brief writes the range of `points` (positions + normals, if available), using the \ref IOStreamOFF.
\tparam PointRange is a model of `ConstRange`. The value type of
its iterator is the key type of the named parameter `point_map`.
\tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters"
\param os output stream
\param points input point range
\param np an 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 `ReadablePropertyMap` with value type `geom_traits::Point_3`}
\cgalParamDefault{`CGAL::Identity_property_map<geom_traits::Point_3>`}
\cgalParamNEnd
\cgalParamNBegin{normal_map}
\cgalParamDescription{a property map associating normals to the elements of the point range}
\cgalParamType{a model of `ReadablePropertyMap` with value type `geom_traits::Vector_3`}
\cgalParamDefault{If this parameter is omitted, normals are not written in the output stream.}
\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{stream_precision}
\cgalParamDescription{a parameter used to set the precision (i.e. how many digits are generated) of the output stream}
\cgalParamType{int}
\cgalParamDefault{the precision of the stream `os`}
\cgalParamNEnd
\cgalNamedParamsEnd
\returns `true` if writing was successful, `false` otherwise.
*/
template <typename PointRange, typename CGAL_NP_TEMPLATE_PARAMETERS>
bool write_OFF(std::ostream& os,
const PointRange& points,
const CGAL_NP_CLASS& np = parameters::default_values()
#ifndef DOXYGEN_RUNNING
, std::enable_if_t<internal::is_Range<PointRange>::value>* = nullptr
#endif
);
/**
\ingroup PkgStreamSupportIoFuncsOFF
\brief writes the range of `points` (positions + normals, if available), using the \ref IOStreamOFF.
\tparam PointRange is a model of `ConstRange`. The value type of
its iterator is the key type of the named parameter `point_map`.
\tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters"
\param filename the path to the output file
\param points input point range
\param np an 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 `ReadablePropertyMap` with value type `geom_traits::Point_3`}
\cgalParamDefault{`CGAL::Identity_property_map<geom_traits::Point_3>`}
\cgalParamNEnd
\cgalParamNBegin{normal_map}
\cgalParamDescription{a property map associating normals to the elements of the point range}
\cgalParamType{a model of `ReadablePropertyMap` with value type `geom_traits::Vector_3`}
\cgalParamDefault{If this parameter is omitted, normals are not written in the output file.}
\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{stream_precision}
\cgalParamDescription{a parameter used to set the precision (i.e. how many digits are generated) of the output stream}
\cgalParamType{int}
\cgalParamDefault{`6`}
\cgalParamNEnd
\cgalNamedParamsEnd
\returns `true` if writing was successful, `false` otherwise.
\sa \ref IOStreamOFF
*/
template <typename PointRange,
typename CGAL_NP_TEMPLATE_PARAMETERS>
bool write_OFF(const std::string& filename,
const PointRange& points,
const CGAL_NP_CLASS& np = parameters::default_values()
#ifndef DOXYGEN_RUNNING
, std::enable_if_t<internal::is_Range<PointRange>::value>* = nullptr
#endif
);
} // namespace IO
} // namespace CGAL

View File

@ -1,18 +1,21 @@
// Copyright (c) 2007-09 INRIA Sophia-Antipolis (France).
// All rights reserved.
// Copyright (c) 1997
// Utrecht University (The Netherlands),
// ETH Zurich (Switzerland),
// INRIA Sophia-Antipolis (France),
// Max-Planck-Institute Saarbruecken (Germany),
// and Tel-Aviv University (Israel). All rights reserved.
//
// This file is part of CGAL (www.cgal.org).
// This file is part of CGAL (www.cgal.org);
//
// $URL$
// $Id$
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial
// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial
//
// Author(s) : Pierre Alliez and Laurent Saboret
#ifndef CGAL_POINT_SET_PROCESSING_READ_OFF_POINTS_H
#define CGAL_POINT_SET_PROCESSING_READ_OFF_POINTS_H
#ifndef CGAL_IO_OFF_READ_OFF_POINTS_H
#define CGAL_IO_OFF_READ_OFF_POINTS_H
#include <CGAL/license/Point_set_processing_3.h>
#include <CGAL/IO/io.h>
#include <CGAL/property_map.h>
@ -21,10 +24,12 @@
#include <CGAL/Kernel_traits.h>
#include <CGAL/iterator.h>
#include <CGAL/type_traits/is_iterator.h>
#include <CGAL/IO/OFF.h>
#include <CGAL/Named_function_parameters.h>
#include <CGAL/boost/graph/named_params_helper.h>
#include <iostream>
#include <fstream>
#include <sstream>
@ -35,54 +40,14 @@ namespace CGAL {
namespace IO {
/**
\ingroup PkgPointSetProcessing3IOOff
\brief reads points (positions + normals, if available), using the \ref IOStreamOFF.
\tparam OutputIteratorValueType type of objects that can be put in `PointOutputIterator`.
It must be a model of `DefaultConstructible` and defaults to `value_type_traits<PointOutputIterator>::%type`.
It 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 is input stream
\param output output iterator over points
\param np an 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<geom_traits::Point_3>`}
\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
\cgalNamedParamsEnd
\returns `true` if reading was successful, `false` otherwise.
\sa \ref IOStreamOFF
*/
// doxygen in ../OFF.h
template <typename OutputIteratorValueType,
typename PointOutputIterator,
typename CGAL_NP_TEMPLATE_PARAMETERS>
typename CGAL_NP_TEMPLATE_PARAMETERS_NO_DEFAULT>
bool read_OFF(std::istream& is,
PointOutputIterator output,
const CGAL_NP_CLASS& np = parameters::default_values()
#ifndef DOXYGEN_RUNNING
, std::enable_if_t<CGAL::is_iterator<PointOutputIterator>::value>* = nullptr
#endif
const CGAL_NP_CLASS& np,
std::enable_if_t<CGAL::is_iterator<PointOutputIterator>::value>*
)
{
using parameters::choose_parameter;
@ -194,54 +159,14 @@ bool read_OFF(std::istream& is,
return true;
}
/**
\ingroup PkgPointSetProcessing3IOOff
\brief reads points (positions + normals, if available), using the \ref IOStreamOFF.
\tparam OutputIteratorValueType type of objects that can be put in `PointOutputIterator`.
It must be a model of `DefaultConstructible` and defaults to `value_type_traits<PointOutputIterator>::%type`.
It 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 input file name
\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<geom_traits::Point_3>`}
\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
\cgalNamedParamsEnd
\returns `true` if reading was successful, `false` otherwise.
\sa \ref IOStreamOFF
*/
// doxygen in ../OFF.h
template <typename OutputIteratorValueType,
typename PointOutputIterator,
typename CGAL_NP_TEMPLATE_PARAMETERS>
typename CGAL_NP_TEMPLATE_PARAMETERS_NO_DEFAULT>
bool read_OFF(const std::string& fname,
PointOutputIterator output,
const CGAL_NP_CLASS& np = parameters::default_values()
#ifndef DOXYGEN_RUNNING
, std::enable_if_t<CGAL::is_iterator<PointOutputIterator>::value>* = nullptr
#endif
const CGAL_NP_CLASS& np,
std::enable_if_t<CGAL::is_iterator<PointOutputIterator>::value>*
)
{
std::ifstream is(fname);
@ -273,4 +198,4 @@ bool read_OFF(const std::string& fname, OutputIterator output, const CGAL_NP_CLA
} // namespace CGAL
#endif // CGAL_POINT_SET_PROCESSING_READ_OFF_POINTS_H
#endif // CGAL_IO_OFF_READ_OFF_POINTS_H

View File

@ -0,0 +1,119 @@
// Copyright (c) 1997
// Utrecht University (The Netherlands),
// ETH Zurich (Switzerland),
// INRIA Sophia-Antipolis (France),
// Max-Planck-Institute Saarbruecken (Germany),
// and Tel-Aviv University (Israel). All rights reserved.
//
// This file is part of CGAL (www.cgal.org);
//
// $URL$
// $Id$
// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial
//
// Author(s) : Pierre Alliez and Laurent Saboret
#ifndef CGAL_IO_OFF_WRITE_OFF_POINTS_H
#define CGAL_IO_OFF_WRITE_OFF_POINTS_H
#include <CGAL/IO/helpers.h>
#include <CGAL/IO/OFF.h>
#include <CGAL/Named_function_parameters.h>
#include <CGAL/boost/graph/named_params_helper.h>
#include <CGAL/property_map.h>
#include <CGAL/Iterator_range.h>
#include <CGAL/assertions.h>
#include <CGAL/IO/OFF.h>
#include <iostream>
#include <fstream>
#include <iterator>
#include <type_traits>
namespace CGAL {
namespace Point_set_processing_3 {
namespace internal {
template <typename PointRange, typename CGAL_NP_TEMPLATE_PARAMETERS>
bool write_OFF_PSP(std::ostream& os,
const PointRange& points,
const CGAL_NP_CLASS& np = CGAL::parameters::default_values())
{
using CGAL::parameters::is_default_parameter;
// basic geometric types
typedef Point_set_processing_3_np_helper<PointRange, CGAL_NP_CLASS> NP_helper;
typedef typename NP_helper::Const_point_map PointMap;
typedef typename NP_helper::Normal_map NormalMap;
const bool has_normals = NP_helper::has_normal_map(points, np);
PointMap point_map = NP_helper::get_const_point_map(points, np);
NormalMap normal_map = NP_helper::get_normal_map(points, np);
CGAL_precondition(points.begin() != points.end());
if(!os)
{
std::cerr << "Error: cannot open file" << std::endl;
return false;
}
set_stream_precision_from_NP(os, np);
// Write header
if (has_normals)
os << "NOFF" << std::endl;
else
os << "OFF" << std::endl;
os << points.size() << " 0 0" << std::endl;
// Write positions + normals
for(typename PointRange::const_iterator it = points.begin(); it != points.end(); it++)
{
os << get(point_map, *it);
if (has_normals)
os << " " << get(normal_map, *it);
os << "\n";
}
os << std::flush;
return !os.fail();
}
} // namespace internal
} // namespace Point_set_processing_3
namespace IO {
// // doxygen in ../OFF.h
template <typename PointRange, typename CGAL_NP_TEMPLATE_PARAMETERS_NO_DEFAULT>
bool write_OFF(std::ostream& os,
const PointRange& points,
const CGAL_NP_CLASS& np,
std::enable_if_t<internal::is_Range<PointRange>::value>*
)
{
return Point_set_processing_3::internal::write_OFF_PSP(os, points, np);
}
// // doxygen in ../OFF.h
template <typename PointRange,
typename CGAL_NP_TEMPLATE_PARAMETERS_NO_DEFAULT>
bool write_OFF(const std::string& filename,
const PointRange& points,
const CGAL_NP_CLASS& np, std::enable_if_t<internal::is_Range<PointRange>::value>*
)
{
std::ofstream os(filename);
set_stream_precision_from_NP(os, np);
return write_OFF(os, points, np);
}
} // IO namespace
} // namespace CGAL
#endif // CGAL_IO_OFF_WRITE_OFF_POINTS_H

View File

@ -14,8 +14,8 @@
#include <CGAL/IO/PLY/PLY_reader.h>
#include <CGAL/IO/PLY/PLY_writer.h>
#include <CGAL/IO/helpers.h>
#include <CGAL/IO/helpers.h>
#include <CGAL/Named_function_parameters.h>
#include <CGAL/boost/graph/named_params_helper.h>
#include <CGAL/property_map.h>
@ -549,7 +549,7 @@ bool write_PLY(const std::string& fname,
const CGAL_NP_CLASS& np = parameters::default_values()
#ifndef DOXYGEN_RUNNING
, std::enable_if_t<internal::is_Range<PolygonRange>::value>* = nullptr
#endif
#endif // DOXYGEN_RUNNING
)
{
const bool binary = CGAL::parameters::choose_parameter(CGAL::parameters::get_parameter(np, internal_np::use_binary_mode), true);
@ -567,8 +567,429 @@ bool write_PLY(const std::string& fname,
}
}
#ifdef DOXYGEN_RUNNING
/**
\ingroup PkgStreamSupportIoFuncsPLY
Class used to identify a %PLY property as a type and a name.
\sa `read_PLY_with_properties()`
*/
template <typename T>
struct PLY_property
{
typedef T type;
const char* name;
PLY_property(const char* name) : name(name) { }
};
/**
\ingroup PkgStreamSupportIoFuncsPLY
Generates a %PLY property handler to read 3D points. Points are
constructed from the input using 3 %PLY properties of type `FT`
and named `x`, `y` and `z`. `FT` is `float` if the points use
`CGAL::Simple_cartesian<float>` and `double` otherwise.
\tparam PointMap the property map used to store points.
\sa `read_PLY_with_properties()`
\sa \ref IOStreamPLY
*/
template <typename PointMap>
std::tuple<PointMap,
typename Kernel_traits<typename PointMap::value_type>::Kernel::Construct_point_3,
PLY_property<FT>, PLY_property<FT>, PLY_property<FT> >
make_ply_point_reader(PointMap point_map);
/**
\ingroup PkgStreamSupportIoFuncsPLY
Generates a %PLY property handler to read 3D normal
vectors. Vectors are constructed from the input using 3 PLY
properties of type `FT` and named `nx`, `ny` and `nz`. `FT`
is `float` if the points use `CGAL::Simple_cartesian<float>` and
`double` otherwise.
\tparam VectorMap the property map used to store vectors.
\sa `read_PLY_with_properties()`
\sa \ref IOStreamPLY
*/
template <typename VectorMap>
std::tuple<VectorMap,
typename Kernel_traits<typename VectorMap::value_type>::Kernel::Construct_vector_3,
PLY_property<FT>, PLY_property<FT>, PLY_property<FT> >
make_ply_normal_reader(VectorMap normal_map);
#endif // DOXYGEN_RUNNING
/**
\ingroup PkgStreamSupportIoFuncsPLY
\brief reads user-selected points properties from a .ply stream (ASCII or binary).
Potential additional point properties and faces are ignored.
Properties are handled through a variadic list of property
handlers. A `PropertyHandler` can either be:
- A `std::pair<PropertyMap, PLY_property<T> >` if the user wants
to read a %PLY property as a scalar value T (for example, storing
an `int` %PLY property into an `int` variable).
- A `std::tuple<PropertyMap, Constructor,
PLY_property<T>...>` if the user wants to use one or several PLY
properties to construct a complex object (for example, storing 3
`uchar` %PLY properties into a %Color object that can for example
be a `std::array<unsigned char, 3>`). In that case, the
second element of the tuple should be a functor that constructs
the value type of `PropertyMap` from N objects of types `T`.
\attention To read a binary file, the flag `std::ios::binary` must be set during the creation of the `ifstream`.
\tparam OutputIteratorValueType type of objects that can be put in `PointOutputIterator`.
It must be a model of `DefaultConstructible` and defaults to `value_type_traits<PointOutputIterator>::%type`.
It can be omitted when the default is fine.
\tparam PointOutputIterator iterator over output points.
\tparam PropertyHandler handlers to recover properties.
\returns `true` if reading was successful, `false` otherwise.
\sa \ref IOStreamPLY
\sa `make_ply_point_reader()`
\sa `make_ply_normal_reader()`
*/
template <typename OutputIteratorValueType,
typename PointOutputIterator,
typename ... PropertyHandler>
bool read_PLY_with_properties(std::istream& is,
PointOutputIterator output,
PropertyHandler&& ... properties);
/**
\ingroup PkgStreamSupportIoFuncsPLY
\brief reads points (positions + normals, if available), using the \ref IOStreamPLY.
Potential additional point properties and faces are ignored.
\attention To read a binary file, the flag `std::ios::binary` must be set during the creation of the `ifstream`.
\tparam OutputIteratorValueType type of objects that can be put in `PointOutputIterator`.
It must be a model of `DefaultConstructible` and defaults to `value_type_traits<PointOutputIterator>::%type`.
It 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 is input stream.
\param output output iterator over points.
\param np an 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<geom_traits::Point_3>`}
\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
\cgalNamedParamsEnd
\returns `true` if reading was successful, `false` otherwise.
\sa `read_PLY_with_properties()`
*/
template <typename OutputIteratorValueType,
typename PointOutputIterator,
typename CGAL_NP_TEMPLATE_PARAMETERS>
bool read_PLY(std::istream& is,
PointOutputIterator output,
const CGAL_NP_CLASS& np = parameters::default_values()
#ifndef DOXYGEN_RUNNING
, std::enable_if_t<CGAL::is_iterator<PointOutputIterator>::value>* = nullptr
#endif
);
/**
\ingroup PkgStreamSupportIoFuncsPLY
\brief reads points (positions + normals, if available), using the \ref IOStreamPLY.
Potential additional point properties and faces are ignored.
\tparam OutputIteratorValueType type of objects that can be put in `PointOutputIterator`.
It must be a model of `DefaultConstructible` and defaults to `value_type_traits<PointOutputIterator>::%type`.
It 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 input file name.
\param output output iterator over points.
\param np optional sequence of \ref bgl_namedparameters "Named Parameters" among the ones listed below.
\cgalNamedParamsBegin
\cgalParamNBegin{use_binary_mode}
\cgalParamDescription{indicates whether data should be read in binary (`true`) or in \ascii (`false`)}
\cgalParamType{Boolean}
\cgalParamDefault{`true`}
\cgalParamNEnd
\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<geom_traits::Point_3>`}
\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
\cgalNamedParamsEnd
\returns `true` if reading was successful, `false` otherwise.
\sa \ref IOStreamPLY
\sa `read_PLY_with_properties()`
*/
template <typename OutputIteratorValueType,
typename PointOutputIterator,
typename CGAL_NP_TEMPLATE_PARAMETERS>
bool read_PLY(const std::string& fname,
PointOutputIterator output,
const CGAL_NP_CLASS& np = parameters::default_values()
#ifndef DOXYGEN_RUNNING
, std::enable_if_t<CGAL::is_iterator<PointOutputIterator>::value>* = nullptr
#endif
);
#ifdef DOXYGEN_RUNNING // Document some parts from Stream_support here for convenience
/**
\ingroup PkgStreamSupportIoFuncsPLY
Generates a %PLY property handler to write 3D points. Points are
written as 3 %PLY properties of type `FT` and named `x`, `y` and
`z`. `FT` is `float` if the points use
`CGAL::Simple_cartesian<float>` and `double` otherwise.
\tparam PointMap the property map used to store points.
\sa `write_PLY_with_properties()`
\sa \ref IOStreamPLY
*/
template <typename PointMap>
std::tuple<PointMap, PLY_property<FT>, PLY_property<FT>, PLY_property<FT> >
make_ply_point_writer(PointMap point_map);
/**
\ingroup PkgStreamSupportIoFuncsPLY
Generates a %PLY property handler to write 3D normal
vectors. Vectors are written as 3 %PLY properties of type `FT`
and named `nx`, `ny` and `nz`. `FT` is `float` if the vectors use
`CGAL::Simple_cartesian<float>` and `double` otherwise.
\tparam VectorMap the property map used to store vectors.
\sa `write_PLY_with_properties()`
\sa \ref IOStreamPLY
*/
template <typename VectorMap>
std::tuple<VectorMap, PLY_property<FT>, PLY_property<FT>, PLY_property<FT> >
make_ply_normal_writer(VectorMap normal_map);
#endif
/**
\ingroup PkgStreamSupportIoFuncsPLY
\brief writes the range of `points` with properties using \ref IOStreamPLY.
Properties are handled through a variadic list of property
handlers. A `PropertyHandler` can either be:
- A `std::pair<PropertyMap, PLY_property<T> >` if the user wants
to write a scalar value T as a %PLY property (for example, writing
an `int` variable as an `int` %PLY property).
- A `std::tuple<PropertyMap, PLY_property<T>...>` if the
user wants to write a complex object as several %PLY
properties. In that case, a specialization of `Output_rep` must
be provided for `PropertyMap::value_type` that handles both ASCII
and binary output (see `CGAL::IO::get_mode()`).
\attention To write to a binary file, the flag `std::ios::binary` must be set during the creation
of the `ofstream`, and the \link PkgStreamSupportEnumRef `IO::Mode` \endlink
of the stream must be set to `BINARY`.
\tparam PointRange is a model of `ConstRange`. The value type of
its iterator is the key type of the `PropertyMap` objects provided
within the `PropertyHandler` parameter.
\tparam PropertyHandler handlers to recover properties.
\returns `true` if writing was successful, `false` otherwise.
\sa \ref IOStreamPLY
\sa `make_ply_point_writer()`
\sa `make_ply_normal_writer()`
*/
template <typename PointRange,
typename ... PropertyHandler>
bool write_PLY_with_properties(std::ostream& os, ///< output stream.
const PointRange& points, ///< input point range.
PropertyHandler&& ... properties); ///< parameter pack of property handlers
/**
\ingroup PkgStreamSupportIoFuncsPLY
\brief writes the range of `points` (positions + normals, if available) using \ref IOStreamPLY.
\attention To write to a binary file, the flag `std::ios::binary` must be set during the creation
of the `ofstream`, and the \link PkgStreamSupportEnumRef `IO::Mode` \endlink
of the stream must be set to `BINARY`.
\tparam PointRange is a model of `ConstRange`. The value type of
its iterator is the key type of the named parameter `point_map`.
\tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters"
\param os output stream
\param points input point range
\param np an 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 `ReadablePropertyMap` with value type `geom_traits::Point_3`}
\cgalParamDefault{`CGAL::Identity_property_map<geom_traits::Point_3>`}
\cgalParamNEnd
\cgalParamNBegin{normal_map}
\cgalParamDescription{a property map associating normals to the elements of the point range}
\cgalParamType{a model of `ReadablePropertyMap` with value type `geom_traits::Vector_3`}
\cgalParamDefault{If this parameter is omitted, normals are not written in the output stream.}
\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{stream_precision}
\cgalParamDescription{a parameter used to set the precision (i.e. how many digits are generated) of the output stream}
\cgalParamType{int}
\cgalParamDefault{the precision of the stream `os`}
\cgalParamExtra{This parameter is only meaningful while using \ascii encoding.}
\cgalParamNEnd
\cgalNamedParamsEnd
\returns `true` if writing was successful, `false` otherwise.
\sa `write_PLY_with_properties()`
*/
template <typename PointRange, typename CGAL_NP_TEMPLATE_PARAMETERS>
bool write_PLY(std::ostream& os,
const PointRange& points,
const CGAL_NP_CLASS& np = parameters::default_values()
#ifndef DOXYGEN_RUNNING
, std::enable_if_t<internal::is_Range<PointRange>::value>* = nullptr
#endif
);
/**
\ingroup PkgStreamSupportIoFuncsPLY
\brief writes the range of `points` (positions + normals, if available) using \ref IOStreamPLY.
\tparam PointRange is a model of `ConstRange`. The value type of
its iterator is the key type of the named parameter `point_map`.
\tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters"
\param filename the path to the output file
\param points input point range
\param np an optional sequence of \ref bgl_namedparameters "Named Parameters" among the ones listed below
\cgalNamedParamsBegin
\cgalParamNBegin{use_binary_mode}
\cgalParamDescription{indicates whether data should be written in binary (`true`) or in \ascii (`false`)}
\cgalParamType{Boolean}
\cgalParamDefault{`true`}
\cgalParamNEnd
\cgalParamNBegin{point_map}
\cgalParamDescription{a property map associating points to the elements of the point range}
\cgalParamType{a model of `ReadablePropertyMap` with value type `geom_traits::Point_3`}
\cgalParamDefault{`CGAL::Identity_property_map<geom_traits::Point_3>`}
\cgalParamNEnd
\cgalParamNBegin{normal_map}
\cgalParamDescription{a property map associating normals to the elements of the point range}
\cgalParamType{a model of `ReadablePropertyMap` with value type `geom_traits::Vector_3`}
\cgalParamDefault{If this parameter is omitted, normals are not written in the output file.}
\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{stream_precision}
\cgalParamDescription{a parameter used to set the precision (i.e. how many digits are generated) of the output stream}
\cgalParamType{int}
\cgalParamDefault{`6`}
\cgalParamExtra{This parameter is only meaningful while using \ascii encoding.}
\cgalParamNEnd
\cgalNamedParamsEnd
\returns `true` if writing was successful, `false` otherwise.
\sa `write_PLY_with_properties()`
*/
template <typename PointRange, typename CGAL_NP_TEMPLATE_PARAMETERS>
bool write_PLY(const std::string& filename,
const PointRange& points,
const CGAL_NP_CLASS& np = parameters::default_values()
#ifndef DOXYGEN_RUNNING
, std::enable_if_t<internal::is_Range<PointRange>::value>* = nullptr
#endif
);
} // namespace IO
} // namespace CGAL
#include <CGAL/IO/PLY/read_ply_points.h>
#include <CGAL/IO/PLY/write_ply_points.h>
#endif // CGAL_IO_PLY_H

View File

@ -11,6 +11,7 @@
#ifndef CGAL_IO_PLY_PLY_READER_H
#define CGAL_IO_PLY_PLY_READER_H
#include <CGAL/IO/PLY.h>
#include <CGAL/Container_helper.h>
#include <CGAL/IO/io.h>
#include <CGAL/type_traits/is_iterator.h>

View File

@ -0,0 +1,181 @@
// Copyright (c) 2017 GeometryFactory
//
// This file is part of CGAL (www.cgal.org);
//
// $URL$
// $Id$
// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial
//
// Author(s) : Simon Giraudot
#ifndef CGAL_IO_PLY_READ_PLY_POINTS_H
#define CGAL_IO_PLY_READ_PLY_POINTS_H
#include <CGAL/config.h>
#include <CGAL/IO/PLY.h>
#include <CGAL/property_map.h>
#include <CGAL/value_type_traits.h>
#include <CGAL/Kernel_traits.h>
#include <CGAL/IO/io.h>
#include <CGAL/Named_function_parameters.h>
#include <CGAL/boost/graph/named_params_helper.h>
#include <boost/version.hpp>
#include <boost/cstdint.hpp>
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <tuple>
namespace CGAL {
namespace IO {
// documentation in ../PLY.h
template <typename OutputIteratorValueType,
typename PointOutputIterator,
typename ... PropertyHandler>
bool read_PLY_with_properties(std::istream& is,
PointOutputIterator output,
PropertyHandler&& ... properties)
{
if(!is)
return false;
internal::PLY_reader reader(true);
if(!(reader.init(is)))
{
is.setstate(std::ios::failbit);
return false;
}
for(std::size_t i = 0; i < reader.number_of_elements(); ++ i)
{
internal::PLY_element& element = reader.element(i);
for(std::size_t j = 0; j < element.number_of_items(); ++ j)
{
for(std::size_t k = 0; k < element.number_of_properties(); ++ k)
{
internal::PLY_read_number* property = element.property(k);
property->get(is);
if(is.fail())
return false;
}
if(element.name() == "vertex" || element.name() == "vertices")
{
OutputIteratorValueType new_element;
internal::process_properties(element, new_element, std::forward<PropertyHandler>(properties)...);
*(output ++) = new_element;
}
}
}
return true;
}
/// \cond SKIP_IN_MANUAL
template <typename OutputIterator,
typename ... PropertyHandler>
bool read_PLY_with_properties(std::istream& is,
OutputIterator output,
PropertyHandler&& ... properties)
{
typedef typename value_type_traits<OutputIterator>::type OutputValueType;
return read_PLY_with_properties<OutputValueType>(is, output, std::forward<PropertyHandler>(properties)...);
}
/// \endcond
// documented in ../PLY.h
template <typename OutputIteratorValueType,
typename PointOutputIterator,
typename CGAL_NP_TEMPLATE_PARAMETERS_NO_DEFAULT>
bool read_PLY(std::istream& is,
PointOutputIterator output,
const CGAL_NP_CLASS& np ,
std::enable_if_t<CGAL::is_iterator<PointOutputIterator>::value>*
)
{
using parameters::choose_parameter;
using parameters::get_parameter;
typedef Point_set_processing_3::Fake_point_range<OutputIteratorValueType> PointRange;
// basic geometric types
typedef Point_set_processing_3_np_helper<PointRange, CGAL_NP_CLASS> NP_helper;
typedef typename NP_helper::Point_map PointMap;
typedef typename NP_helper::Normal_map NormalMap;
PointMap point_map = NP_helper::get_point_map(np);
NormalMap normal_map = NP_helper::get_normal_map(np);
return read_PLY_with_properties(is, output,
make_ply_point_reader(point_map),
make_ply_normal_reader(normal_map));
}
// documentation in ../PLY.h
template <typename OutputIteratorValueType,
typename PointOutputIterator,
typename CGAL_NP_TEMPLATE_PARAMETERS_NO_DEFAULT>
bool read_PLY(const std::string& fname,
PointOutputIterator output,
const CGAL_NP_CLASS& np,
std::enable_if_t<CGAL::is_iterator<PointOutputIterator>::value>*
)
{
const bool binary = CGAL::parameters::choose_parameter(CGAL::parameters::get_parameter(np, internal_np::use_binary_mode), true);
if(binary)
{
std::ifstream is(fname, std::ios::binary);
CGAL::IO::set_mode(is, CGAL::IO::BINARY);
return read_PLY<OutputIteratorValueType>(is, output, np);
}
else
{
std::ifstream is(fname);
CGAL::IO::set_mode(is, CGAL::IO::ASCII);
return read_PLY<OutputIteratorValueType>(is, output, np);
}
}
/// \cond SKIP_IN_MANUAL
// variants with default output iterator value type
template <typename OutputIterator, typename CGAL_NP_TEMPLATE_PARAMETERS>
bool read_PLY(std::istream& is, OutputIterator output, const CGAL_NP_CLASS& np = parameters::default_values(),
std::enable_if_t<CGAL::is_iterator<OutputIterator>::value>* = nullptr)
{
return read_PLY<typename value_type_traits<OutputIterator>::type>(is, output, np);
}
template <typename OutputIterator,typename CGAL_NP_TEMPLATE_PARAMETERS>
bool read_PLY(const std::string& fname, OutputIterator output, const CGAL_NP_CLASS& np = parameters::default_values(),
std::enable_if_t<CGAL::is_iterator<OutputIterator>::value>* = nullptr)
{
return read_PLY<typename value_type_traits<OutputIterator>::type>(fname, output, np);
}
/// \endcond
} // namespace IO
} // namespace CGAL
#undef TRY_TO_GENERATE_POINT_PROPERTY
#undef TRY_TO_GENERATE_SIZED_FACE_PROPERTY
#undef TRY_TO_GENERATE_FACE_PROPERTY
#endif // CGAL_IO_PLY_READ_PLY_POINTS_H

View File

@ -0,0 +1,137 @@
// Copyright (c) 1997
// Utrecht University (The Netherlands),
// ETH Zurich (Switzerland),
// INRIA Sophia-Antipolis (France),
// Max-Planck-Institute Saarbruecken (Germany),
// and Tel-Aviv University (Israel). All rights reserved.
//
// This file is part of CGAL (www.cgal.org);
//
// $URL$
// $Id$
// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial
//
// Author(s) : Simon Giraudot
#ifndef CGAL_IO_PLY_WRITE_PLY_POINTS_H
#define CGAL_IO_PLY_WRITE_PLY_POINTS_H
#include <CGAL/IO/helpers.h>
#include <CGAL/IO/PLY.h>
#include <CGAL/property_map.h>
#include <CGAL/assertions.h>
#include <CGAL/Iterator_range.h>
#include <CGAL/Named_function_parameters.h>
#include <CGAL/boost/graph/named_params_helper.h>
#include <boost/version.hpp>
#include <iostream>
#include <fstream>
#include <iterator>
#include <tuple>
#include <type_traits>
namespace CGAL {
namespace IO {
// documented in ../PLY.h
template <typename PointRange,
typename ... PropertyHandler>
bool write_PLY_with_properties(std::ostream& os, ///< output stream.
const PointRange& points, ///< input point range.
PropertyHandler&& ... properties) ///< parameter pack of property handlers
{
CGAL_precondition(points.begin() != points.end());
if(!os)
{
std::cerr << "Error: cannot open file" << std::endl;
return false;
}
// Write header
os << "ply" << std::endl
<< ((get_mode(os) == BINARY) ? "format binary_little_endian 1.0" : "format ascii 1.0") << std::endl
<< "comment Generated by the CGAL library" << std::endl
<< "element vertex " << points.size() << std::endl;
internal::output_property_header (os, std::forward<PropertyHandler>(properties)...);
os << "end_header" << std::endl;
// Write positions + normals
for(typename PointRange::const_iterator it = points.begin(); it != points.end(); it++)
internal::output_properties (os, it, std::forward<PropertyHandler>(properties)...);
return !os.fail();
}
// documented in ../PLY.h
template <typename PointRange, typename CGAL_NP_TEMPLATE_PARAMETERS_NO_DEFAULT>
bool write_PLY(std::ostream& os,
const PointRange& points,
const CGAL_NP_CLASS& np
, std::enable_if_t<internal::is_Range<PointRange>::value>*
)
{
using parameters::choose_parameter;
using parameters::get_parameter;
// basic geometric types
typedef Point_set_processing_3_np_helper<PointRange, CGAL_NP_CLASS> NP_helper;
typedef typename NP_helper::Const_point_map PointMap;
typedef typename NP_helper::Normal_map NormalMap;
const bool has_normals = NP_helper::has_normal_map(points, np);
PointMap point_map = NP_helper::get_const_point_map(points, np);
NormalMap normal_map = NP_helper::get_normal_map(points, np);
if(!os)
{
std::cerr << "Error: cannot open file" << std::endl;
return false;
}
set_stream_precision_from_NP(os, np);
if(has_normals)
return write_PLY_with_properties(os, points,
make_ply_point_writer(point_map),
make_ply_normal_writer(normal_map));
return write_PLY_with_properties(os, points, make_ply_point_writer(point_map));
}
// documented in ../PLY.h
template <typename PointRange, typename CGAL_NP_TEMPLATE_PARAMETERS_NO_DEFAULT>
bool write_PLY(const std::string& filename,
const PointRange& points,
const CGAL_NP_CLASS& np,
std::enable_if_t<internal::is_Range<PointRange>::value>*
)
{
const bool binary = CGAL::parameters::choose_parameter(CGAL::parameters::get_parameter(np, internal_np::use_binary_mode), true);
if(binary)
{
std::ofstream os(filename, std::ios::binary);
CGAL::IO::set_mode(os, CGAL::IO::BINARY);
return write_PLY(os, points, np);
}
else
{
std::ofstream os(filename);
CGAL::IO::set_mode(os, CGAL::IO::ASCII);
return write_PLY(os, points, np);
}
}
} // namespace IO
} // namespace CGAL
#endif // CGAL_IO_PLY_WRITE_PLY_POINTS_H

View File

@ -0,0 +1,236 @@
// Copyright (c) 2017 GeometryFactory
//
// This file is part of CGAL (www.cgal.org);
//
// $URL$
// $Id$
// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial
//
// Author(s) : Simon Giraudot
#ifndef CGAL_IO_XYZ_H
#define CGAL_IO_XYZ_H
#include <fstream>
#include <iostream>
#include <vector>
#include <type_traits>
#include <CGAL/IO/helpers.h>
#include <CGAL/Named_function_parameters.h>
#include <CGAL/boost/graph/named_params_helper.h>
#include <CGAL/Kernel_traits.h>
namespace CGAL {
////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////
// Read
namespace IO {
/**
\ingroup PkgStreamSupportIoFuncsXYZ
\brief reads points (positions + normals, if available), using the \ref IOStreamXYZ.
\tparam OutputIteratorValueType type of objects that can be put in `OutputIterator`.
It must be a model of `DefaultConstructible` and defaults to `value_type_traits<OutputIterator>::%type`.
It can be omitted when the default is fine.
\tparam OutputIterator iterator over output points.
\tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters"
\param is input stream.
\param output output iterator over points.
\param np an 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<geom_traits::Point_3>`}
\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
\cgalNamedParamsEnd
\returns `true` if reading was successful, `false` otherwise.
\sa \ref IOStreamXYZ
*/
template <typename OutputIteratorValueType,
typename OutputIterator,
typename CGAL_NP_TEMPLATE_PARAMETERS>
bool read_XYZ(std::istream& is,
OutputIterator output,
const CGAL_NP_CLASS& np = parameters::default_values());
/**
\ingroup PkgStreamSupportIoFuncsXYZ
\brief reads points (positions + normals, if available), using the \ref IOStreamXYZ.
\tparam OutputIteratorValueType type of objects that can be put in `OutputIterator`.
It must be a model of `DefaultConstructible` and defaults to `value_type_traits<OutputIterator>::%type`.
It can be omitted when the default is fine.
\tparam OutputIterator iterator over output points.
\tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters"
\param fname input file name.
\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<geom_traits::Point_3>`}
\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
\cgalNamedParamsEnd
\returns `true` if reading was successful, `false` otherwise.
\sa \ref IOStreamXYZ
*/
template <typename OutputIteratorValueType,
typename OutputIterator,
typename CGAL_NP_TEMPLATE_PARAMETERS>
bool read_XYZ(const std::string& fname,
OutputIterator output,
const CGAL_NP_CLASS& np = parameters::default_values());
/**
\ingroup PkgStreamSupportIoFuncsXYZ
\brief writes the range of `points` (positions + normals, if available), using the \ref IOStreamXYZ.
\tparam PointRange is a model of `ConstRange`. The value type of
its iterator is the key type of the named parameter `point_map`.
\tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters"
\param os output stream
\param points input point range
\param np an 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 `ReadablePropertyMap` with value type `geom_traits::Point_3`}
\cgalParamDefault{`CGAL::Identity_property_map<geom_traits::Point_3>`}
\cgalParamNEnd
\cgalParamNBegin{normal_map}
\cgalParamDescription{a property map associating normals to the elements of the point range}
\cgalParamType{a model of `ReadablePropertyMap` with value type `geom_traits::Vector_3`}
\cgalParamDefault{If this parameter is omitted, normals are not written in the output stream.}
\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{stream_precision}
\cgalParamDescription{a parameter used to set the precision (i.e. how many digits are generated) of the output stream}
\cgalParamType{int}
\cgalParamDefault{the precision of the stream `os`}
\cgalParamNEnd
\cgalNamedParamsEnd
\returns `true` if writing was successful, `false` otherwise.
*/
template <typename PointRange, typename CGAL_NP_TEMPLATE_PARAMETERS>
bool write_XYZ(std::ostream& os,
const PointRange& points,
const CGAL_NP_CLASS& np = parameters::default_values()
#ifndef DOXYGEN_RUNNING
, std::enable_if_t<internal::is_Range<PointRange>::value>* = nullptr
#endif
);
/**
\ingroup PkgStreamSupportIoFuncsXYZ
\brief writes the range of `points` (positions + normals, if available), using the \ref IOStreamXYZ.
\tparam PointRange is a model of `ConstRange`. The value type of
its iterator is the key type of the named parameter `point_map`.
\tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters"
\param filename path to the output file
\param points input point range
\param np an 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 `ReadablePropertyMap` with value type `geom_traits::Point_3`}
\cgalParamDefault{`CGAL::Identity_property_map<geom_traits::Point_3>`}
\cgalParamNEnd
\cgalParamNBegin{normal_map}
\cgalParamDescription{a property map associating normals to the elements of the point range}
\cgalParamType{a model of `ReadablePropertyMap` with value type `geom_traits::Vector_3`}
\cgalParamDefault{If this parameter is omitted, normals are not written in the output file.}
\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{stream_precision}
\cgalParamDescription{a parameter used to set the precision (i.e. how many digits are generated) of the output stream}
\cgalParamType{int}
\cgalParamDefault{`6`}
\cgalParamNEnd
\cgalNamedParamsEnd
\returns `true` if writing was successful, `false` otherwise.
*/
template <typename PointRange, typename CGAL_NP_TEMPLATE_PARAMETERS>
bool write_XYZ(const std::string& filename,
const PointRange& points,
const CGAL_NP_CLASS& np = parameters::default_values()
#ifndef DOXYGEN_RUNNING
, std::enable_if_t<internal::is_Range<PointRange>::value>* = nullptr
#endif
);
} // namespace IO
} // namespace CGAL
#include <CGAL/IO/XYZ/read_xyz_points.h>
#include <CGAL/IO/XYZ/write_xyz_points.h>
#endif // CGAL_IO_XYZ_H

View File

@ -1,19 +1,22 @@
// Copyright (c) 2007-09 INRIA Sophia-Antipolis (France).
// All rights reserved.
// Copyright (c) 1997
// Utrecht University (The Netherlands),
// ETH Zurich (Switzerland),
// INRIA Sophia-Antipolis (France),
// Max-Planck-Institute Saarbruecken (Germany),
// and Tel-Aviv University (Israel). All rights reserved.
//
// This file is part of CGAL (www.cgal.org).
// This file is part of CGAL (www.cgal.org);
//
// $URL$
// $Id$
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial
// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial
//
// Author(s) : Pierre Alliez and Laurent Saboret
#ifndef CGAL_POINT_SET_PROCESSING_READ_XYZ_POINTS_H
#define CGAL_POINT_SET_PROCESSING_READ_XYZ_POINTS_H
#include <CGAL/license/Point_set_processing_3.h>
#ifndef CGAL_IO_PLY_READ_XYZ_POINTS_H
#define CGAL_IO_PLY_READ_XYZ_POINTS_H
#include <CGAL/IO/XYZ.h>
#include <CGAL/property_map.h>
#include <CGAL/value_type_traits.h>
#include <CGAL/Origin.h>
@ -32,51 +35,13 @@ namespace CGAL {
namespace IO {
/**
\ingroup PkgPointSetProcessing3IOXyz
\brief reads points (positions + normals, if available), using the \ref IOStreamXYZ.
\tparam OutputIteratorValueType type of objects that can be put in `OutputIterator`.
It must be a model of `DefaultConstructible` and defaults to `value_type_traits<OutputIterator>::%type`.
It can be omitted when the default is fine.
\tparam OutputIterator iterator over output points.
\tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters"
\param is input stream.
\param output output iterator over points.
\param np an 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<geom_traits::Point_3>`}
\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
\cgalNamedParamsEnd
\returns `true` if reading was successful, `false` otherwise.
\sa \ref IOStreamXYZ
*/
// doxygen in ../XYZ.h
template <typename OutputIteratorValueType,
typename OutputIterator,
typename CGAL_NP_TEMPLATE_PARAMETERS>
typename CGAL_NP_TEMPLATE_PARAMETERS_NO_DEFAULT>
bool read_XYZ(std::istream& is,
OutputIterator output,
const CGAL_NP_CLASS& np = parameters::default_values())
const CGAL_NP_CLASS& np)
{
using parameters::choose_parameter;
using parameters::get_parameter;
@ -178,51 +143,13 @@ bool read_XYZ(std::istream& is,
return true;
}
/**
\ingroup PkgPointSetProcessing3IOXyz
\brief reads points (positions + normals, if available), using the \ref IOStreamXYZ.
\tparam OutputIteratorValueType type of objects that can be put in `OutputIterator`.
It must be a model of `DefaultConstructible` and defaults to `value_type_traits<OutputIterator>::%type`.
It can be omitted when the default is fine.
\tparam OutputIterator iterator over output points.
\tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters"
\param fname input file name.
\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<geom_traits::Point_3>`}
\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
\cgalNamedParamsEnd
\returns `true` if reading was successful, `false` otherwise.
\sa \ref IOStreamXYZ
*/
// documentation in ../XYZ.h
template <typename OutputIteratorValueType,
typename OutputIterator,
typename CGAL_NP_TEMPLATE_PARAMETERS>
typename CGAL_NP_TEMPLATE_PARAMETERS_NO_DEFAULT>
bool read_XYZ(const std::string& fname,
OutputIterator output,
const CGAL_NP_CLASS& np = parameters::default_values())
const CGAL_NP_CLASS& np)
{
std::ifstream is(fname);
return read_XYZ<OutputIteratorValueType>(is, output, np);
@ -253,4 +180,4 @@ bool read_XYZ(const std::string& fname, OutputIterator output, const CGAL_NP_CLA
} // namespace CGAL
#endif // CGAL_POINT_SET_PROCESSING_READ_XYZ_POINTS_H
#endif // CGAL_IO_PLY_READ_XYZ_POINTS_H

View File

@ -0,0 +1,113 @@
// Copyright (c) 1997
// Utrecht University (The Netherlands),
// ETH Zurich (Switzerland),
// INRIA Sophia-Antipolis (France),
// Max-Planck-Institute Saarbruecken (Germany),
// and Tel-Aviv University (Israel). All rights reserved.
//
// This file is part of CGAL (www.cgal.org);
//
// $URL$
// $Id$
// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial
//
// Author(s) : Pierre Alliez and Laurent Saboret
#ifndef CGAL_POINT_SET_PROCESSING_WRITE_XYZ_POINTS_H
#define CGAL_POINT_SET_PROCESSING_WRITE_XYZ_POINTS_H
#include <CGAL/IO/helpers.h>
#include <CGAL/IO/XYZ.h>
#include <CGAL/property_map.h>
#include <CGAL/assertions.h>
#include <CGAL/Kernel_traits.h>
#include <CGAL/Iterator_range.h>
#include <CGAL/Named_function_parameters.h>
#include <CGAL/boost/graph/named_params_helper.h>
#include <iostream>
#include <fstream>
#include <iterator>
#include <type_traits>
namespace CGAL {
namespace Point_set_processing_3 {
namespace internal {
template <typename PointRange, typename CGAL_NP_TEMPLATE_PARAMETERS>
bool write_XYZ_PSP(std::ostream& os,
const PointRange& points,
const CGAL_NP_CLASS& np = CGAL::parameters::default_values())
{
using CGAL::parameters::choose_parameter;
using CGAL::parameters::get_parameter;
// basic geometric types
typedef Point_set_processing_3_np_helper<PointRange, CGAL_NP_CLASS> NP_helper;
typedef typename NP_helper::Const_point_map PointMap;
typedef typename NP_helper::Normal_map NormalMap;
const bool has_normals = NP_helper::has_normal_map(points, np);
PointMap point_map = NP_helper::get_const_point_map(points, np);
NormalMap normal_map = NP_helper::get_normal_map(points, np);
CGAL_precondition(points.begin() != points.end());
if(!os)
{
std::cerr << "Error: cannot open file" << std::endl;
return false;
}
set_stream_precision_from_NP(os, np);
// Write positions + normals
for(typename PointRange::const_iterator it = points.begin(); it != points.end(); it++)
{
os << get(point_map, *it);
if(has_normals)
os << " " << get(normal_map, *it);
os << "\n";
}
os << std::flush;
return !os.fail();
}
} // namespace internal
} // Point_set_processing_3
namespace IO {
// documented in ../XYZ.h
template <typename PointRange, typename CGAL_NP_TEMPLATE_PARAMETERS_NO_DEFAULT>
bool write_XYZ(std::ostream& os,
const PointRange& points,
const CGAL_NP_CLASS& np,
std::enable_if_t<internal::is_Range<PointRange>::value>*
)
{
return Point_set_processing_3::internal::write_XYZ_PSP(os, points, np);
}
// documented in ../XYZ.h
template <typename PointRange, typename CGAL_NP_TEMPLATE_PARAMETERS_NO_DEFAULT>
bool write_XYZ(const std::string& filename,
const PointRange& points,
const CGAL_NP_CLASS& np,
std::enable_if_t<internal::is_Range<PointRange>::value>*
)
{
std::ofstream os(filename);
return write_XYZ(os, points, np);
}
} // namespace IO
} // namespace CGAL
#endif // CGAL_POINT_SET_PROCESSING_WRITE_XYZ_POINTS_H

View File

@ -0,0 +1,18 @@
// Copyright (c) 2017 GeometryFactory
//
// This file is part of CGAL (www.cgal.org);
//
// $URL$
// $Id$
// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial
//
// Author(s) : Simon Giraudot
#ifndef CGAL_IO_READ_LAS_POINTS_H
#define CGAL_IO_READ_LAS_POINTS_H
#include <CGAL/IO/LAS.h>
#endif // CGAL_IO_READ_LAS_POINTS_H

View File

@ -0,0 +1,16 @@
// Copyright (c) 2017 GeometryFactory
//
// This file is part of CGAL (www.cgal.org);
//
// $URL$
// $Id$
// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial
//
// Author(s) : Simon Giraudot
#ifndef CGAL_IO_READ_OFF_POINTS_H
#define CGAL_IO_READ_OFF_POINTS_H
#include <CGAL/IO/OFF.h>
#endif // CGAL_IO_READ_OFF_POINTS_H

View File

@ -0,0 +1,16 @@
// Copyright (c) 2017 GeometryFactory
//
// This file is part of CGAL (www.cgal.org);
//
// $URL$
// $Id$
// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial
//
// Author(s) : Simon Giraudot
#ifndef CGAL_IO_READ_PLY_POINTS_H
#define CGAL_IO_READ_PLY_POINTS_H
#include <CGAL/IO/PLY.h>
#endif // CGAL_IO_READ_PLY_POINTS_H

View File

@ -1,26 +1,24 @@
// Copyright (c) 2020 Geometry Factory
// All rights reserved.
//
// This file is part of CGAL (www.cgal.org).
// This file is part of CGAL (www.cgal.org);
//
// $URL$
// $Id$
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial
// SPDX-License-Identifier: LGPL-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
#ifndef CGAL_STREAM_SUPPORT_IO_READ_POINTS_H
#define CGAL_STREAM_SUPPORT_IO_READ_POINTS_H
#include <CGAL/license/Point_set_processing_3.h>
#include <CGAL/IO/helpers.h>
#include <CGAL/IO/read_off_points.h>
#include <CGAL/IO/read_ply_points.h>
#include <CGAL/IO/read_xyz_points.h>
#include <CGAL/IO/OFF/read_off_points.h>
#include <CGAL/IO/PLY/read_ply_points.h>
#include <CGAL/IO/XYZ/read_xyz_points.h>
#ifdef CGAL_LINKED_WITH_LASLIB
#include <CGAL/IO/read_las_points.h>
#include <CGAL/IO/LAS/read_las_points.h>
#endif
#include <fstream>
@ -31,7 +29,7 @@ namespace CGAL {
namespace IO {
/**
\ingroup PkgPointSetProcessing3IO
\ingroup IOstreamFunctions
\brief reads the point set from an input file.
@ -120,4 +118,4 @@ bool read_points(const std::string& fname, OutputIterator output, const NamedPar
} } // namespace CGAL::IO
#endif // CGAL_POINT_SET_PROCESSING_READ_POINTS_H
#endif // CGAL_STREAM_SUPPORT_IO_READ_POINTS_H

View File

@ -0,0 +1,18 @@
// Copyright (c) 2017 GeometryFactory
//
// This file is part of CGAL (www.cgal.org);
//
// $URL$
// $Id$
// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial
//
// Author(s) : Simon Giraudot
#ifndef CGAL_IO_READ_XYZ_POINTS_H
#define CGAL_IO_READ_XYZ_POINTS_H
#include <CGAL/IO/XYZ.h>
#endif // CGAL_IO_READ_XYZ_POINTS_H

View File

@ -0,0 +1,17 @@
// Copyright (c) 2017 GeometryFactory
//
// This file is part of CGAL (www.cgal.org);
//
// $URL$
// $Id$
// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial
//
// Author(s) : Simon Giraudot
#ifndef CGAL_IO_WRITE_LAS_POINTS_H
#define CGAL_IO_WRITE_LAS_POINTS_H
#include <CGAL/IO/LAS.h>
#endif // CGAL_IO_WRITE_LAS_POINTS_H

View File

@ -0,0 +1,17 @@
// Copyright (c) 2017 GeometryFactory
//
// This file is part of CGAL (www.cgal.org);
//
// $URL$
// $Id$
// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial
//
// Author(s) : Simon Giraudot
#ifndef CGAL_IO_WRITE_OFF_POINTS_H
#define CGAL_IO_WRITE_OFF_POINTS_H
#include <CGAL/IO/OFF.h>
#endif // CGAL_IO_WRITE_OFF_POINTS_H

View File

@ -0,0 +1,12 @@
// Copyright (c) 2017 GeometryFactory
//
// This file is part of CGAL (www.cgal.org);
//
// $URL$
// $Id$
// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial
//
// Author(s) : Simon Giraudot
#include <CGAL/IO/PLY/write_ply_points.h>

View File

@ -1,26 +1,23 @@
// Copyright (c) 2020 Geometry Factory
// All rights reserved.
//
// This file is part of CGAL (www.cgal.org).
// This file is part of CGAL (www.cgal.org);
//
// $URL$
// $Id$
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial
// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial
//
// Author(s) : Maxime Gimeno
#ifndef CGAL_POINT_SET_PROCESSING_WRITE_POINTS_H
#define CGAL_POINT_SET_PROCESSING_WRITE_POINTS_H
#include <CGAL/license/Point_set_processing_3.h>
#ifndef CGAL_STREAM_SUPPORT_IO_WRITE_POINTS_H
#define CGAL_STREAM_SUPPORT_IO_WRITE_POINTS_H
#include <CGAL/IO/helpers.h>
#include <CGAL/IO/write_off_points.h>
#include <CGAL/IO/write_ply_points.h>
#include <CGAL/IO/write_xyz_points.h>
#include <CGAL/IO/OFF/write_off_points.h>
#include <CGAL/IO/PLY/write_ply_points.h>
#include <CGAL/IO/XYZ/write_xyz_points.h>
#ifdef CGAL_LINKED_WITH_LASLIB
#include <CGAL/IO/write_las_points.h>
#include <CGAL/IO/LAS/write_las_points.h>
#endif
#include <iostream>
@ -31,7 +28,7 @@ namespace CGAL {
namespace IO {
/**
\ingroup PkgPointSetProcessing3IO
\ingroup IOstreamFunctions
\brief writes the range of `points` with properties to a file.
@ -115,4 +112,4 @@ bool write_points(const std::string& fname,
} } // namespace CGAL::IO
#endif // CGAL_POINT_SET_PROCESSING_WRITE_POINTS_H
#endif // CGAL_STREAM_SUPPORT_IO_WRITE_POINTS_H

View File

@ -0,0 +1,17 @@
// Copyright (c) 2017 GeometryFactory
//
// This file is part of CGAL (www.cgal.org);
//
// $URL$
// $Id$
// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial
//
// Author(s) : Simon Giraudot
#ifndef CGAL_IO_WRITE_XYZ_POINTS_H
#define CGAL_IO_WRITE_XYZ_POINTS_H
#include <CGAL/IO/XYZ.h>
#endif // CGAL_IO_WRITE_XYZ_POINTS_H

View File

@ -1,7 +1,7 @@
#include <CGAL/Simple_cartesian.h>
#include <CGAL/config.h>
#include <CGAL/IO/read_ply_points.h>
#include <CGAL/IO/PLY.h>
#include <CGAL/property_map.h>
#include <boost/iterator/function_output_iterator.hpp>

View File

@ -6,7 +6,7 @@
#include <fstream>
#include <string>
#include <CGAL/IO/read_xyz_points.h>
#include <CGAL/IO/XYZ.h>
#include <CGAL/Random.h>
#define CGAL_TRIANGULATION_3_VERBOSE_TRAVERSER_EXAMPLE

View File

@ -9,7 +9,7 @@
#include <string>
#include <vector>
#include <CGAL/IO/read_xyz_points.h>
#include <CGAL/IO/XYZ.h>
#include <CGAL/Random.h>
// Define the kernel.