mirror of https://github.com/CGAL/cgal
Change API to named parameters in all PSP IO functions/examples/tests/doc
This commit is contained in:
parent
16697b79f9
commit
506a5d2f33
|
|
@ -71,21 +71,15 @@ format.
|
|||
## IO (XYZ/OFF Formats) ##
|
||||
|
||||
- `CGAL::read_off_points()`
|
||||
- `CGAL::read_off_points_and_normals()`
|
||||
- `CGAL::read_xyz_points()`
|
||||
- `CGAL::read_xyz_points_and_normals()`
|
||||
- `CGAL::write_off_points()`
|
||||
- `CGAL::write_off_points_and_normals()`
|
||||
- `CGAL::write_xyz_points()`
|
||||
- `CGAL::write_xyz_points_and_normals()`
|
||||
|
||||
## IO (PLY Format) ##
|
||||
|
||||
- `CGAL::read_ply_points()`
|
||||
- `CGAL::read_ply_points_and_normals()`
|
||||
- `CGAL::read_ply_points_with_properties()`
|
||||
- `CGAL::write_ply_points()`
|
||||
- `CGAL::write_ply_points_and_normals()`
|
||||
- `CGAL::write_ply_points_with_properties()`
|
||||
- `CGAL::PLY_property<T>`
|
||||
- `CGAL::make_ply_point_reader()`
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ int main(int argc, char*argv[])
|
|||
if (!stream ||
|
||||
!CGAL::read_xyz_points(
|
||||
stream, std::back_inserter(points),
|
||||
CGAL::Nth_of_tuple_property_map<1,IndexedPointWithColorTuple>()))
|
||||
CGAL::parameters::point_map(CGAL::Nth_of_tuple_property_map<1,IndexedPointWithColorTuple>())))
|
||||
{
|
||||
std::cerr << "Error: cannot read file " << fname << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
|
|
|
|||
|
|
@ -33,10 +33,10 @@ int main(int argc, char*argv[])
|
|||
std::vector<PointVectorPair> points;
|
||||
std::ifstream stream(input_filename);
|
||||
if (!stream ||
|
||||
!CGAL::read_xyz_points_and_normals(stream,
|
||||
!CGAL::read_xyz_points(stream,
|
||||
std::back_inserter(points),
|
||||
CGAL::First_of_pair_property_map<PointVectorPair>(),
|
||||
CGAL::Second_of_pair_property_map<PointVectorPair>()))
|
||||
CGAL::parameters::point_map(CGAL::First_of_pair_property_map<PointVectorPair>()).
|
||||
normal_map(CGAL::Second_of_pair_property_map<PointVectorPair>())))
|
||||
{
|
||||
std::cerr << "Error: cannot read file " << input_filename << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
|
|
@ -55,18 +55,18 @@ int main(int argc, char*argv[])
|
|||
CGAL::bilateral_smooth_point_set <Concurrency_tag>(
|
||||
points,
|
||||
k,
|
||||
sharpness_angle,
|
||||
CGAL::parameters::point_map(CGAL::First_of_pair_property_map<PointVectorPair>()).
|
||||
normal_map(CGAL::Second_of_pair_property_map<PointVectorPair>()));
|
||||
normal_map(CGAL::Second_of_pair_property_map<PointVectorPair>()).
|
||||
sharpness_angle (sharpness_angle));
|
||||
}
|
||||
|
||||
//// Save point set.
|
||||
std::ofstream out(output_filename);
|
||||
if (!out ||
|
||||
!CGAL::write_xyz_points_and_normals(
|
||||
out, points.begin(), points.end(),
|
||||
CGAL::First_of_pair_property_map<PointVectorPair>(),
|
||||
CGAL::Second_of_pair_property_map<PointVectorPair>()))
|
||||
!CGAL::write_xyz_points(
|
||||
out, points,
|
||||
CGAL::parameters::point_map(CGAL::First_of_pair_property_map<PointVectorPair>()).
|
||||
normal_map(CGAL::Second_of_pair_property_map<PointVectorPair>())))
|
||||
{
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,10 +33,10 @@ int main(int argc, char* argv[])
|
|||
std::ifstream stream(input_filename);
|
||||
|
||||
if (!stream ||
|
||||
!CGAL::read_xyz_points_and_normals(stream,
|
||||
!CGAL::read_xyz_points(stream,
|
||||
std::back_inserter(points),
|
||||
CGAL::First_of_pair_property_map<PointVectorPair>(),
|
||||
CGAL::Second_of_pair_property_map<PointVectorPair>()))
|
||||
CGAL::parameters::point_map(CGAL::First_of_pair_property_map<PointVectorPair>()).
|
||||
normal_map(CGAL::Second_of_pair_property_map<PointVectorPair>())))
|
||||
{
|
||||
std::cerr << "Error: cannot read file " << input_filename << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
|
|
@ -63,10 +63,10 @@ int main(int argc, char* argv[])
|
|||
std::ofstream out(output_filename);
|
||||
|
||||
if (!out ||
|
||||
!CGAL::write_xyz_points_and_normals(
|
||||
out, points.begin(), points.end(),
|
||||
CGAL::First_of_pair_property_map<PointVectorPair>(),
|
||||
CGAL::Second_of_pair_property_map<PointVectorPair>()))
|
||||
!CGAL::write_xyz_points(
|
||||
out, points,
|
||||
CGAL::parameters::point_map(CGAL::First_of_pair_property_map<PointVectorPair>()).
|
||||
normal_map(CGAL::Second_of_pair_property_map<PointVectorPair>())))
|
||||
{
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ int main (int , char**) {
|
|||
if (!stream ||
|
||||
!CGAL::read_off_points(stream,
|
||||
std::back_inserter(points),
|
||||
CGAL::First_of_pair_property_map<PointVectorPair>()))
|
||||
CGAL::parameters::point_map(CGAL::First_of_pair_property_map<PointVectorPair>())))
|
||||
{
|
||||
std::cerr << "Error: cannot read file data/fandisk.off" << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
|
|
@ -37,9 +37,10 @@ int main (int , char**) {
|
|||
double R = 0.2,
|
||||
r = 0.1;
|
||||
std::vector<Covariance> cov;
|
||||
CGAL::First_of_pair_property_map<PointVectorPair> point_pmap;
|
||||
CGAL::First_of_pair_property_map<PointVectorPair> point_map;
|
||||
|
||||
CGAL::compute_vcm(points.begin(), points.end(), point_pmap, cov, R, r, Kernel());
|
||||
CGAL::compute_vcm(points, cov, R, r,
|
||||
CGAL::parameters::point_map (point_map).geom_traits (Kernel()));
|
||||
|
||||
// Find the points on the edges.
|
||||
// Note that this step is not expensive and can be done several time to get better results
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ int main(int argc, char*argv[])
|
|||
<< (memory>>20) << " Mib allocated." << std::endl;
|
||||
|
||||
std::ofstream f ("out.xyz");
|
||||
CGAL::write_xyz_points (f, points.begin (), points.end ());
|
||||
CGAL::write_xyz_points (f, points);
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -260,7 +260,7 @@ int main(int argc, char * argv[])
|
|||
success = stream &&
|
||||
CGAL::read_off_points(stream,
|
||||
std::back_inserter(points),
|
||||
CGAL::First_of_pair_property_map<PointVectorPair>());
|
||||
CGAL::parameters::point_map(CGAL::First_of_pair_property_map<PointVectorPair>()));
|
||||
}
|
||||
// If XYZ file format
|
||||
else if (extension == ".xyz" || extension == ".XYZ" ||
|
||||
|
|
@ -270,7 +270,7 @@ int main(int argc, char * argv[])
|
|||
success = stream &&
|
||||
CGAL::read_xyz_points(stream,
|
||||
std::back_inserter(points),
|
||||
CGAL::First_of_pair_property_map<PointVectorPair>());
|
||||
CGAL::parameters::point_map(CGAL::First_of_pair_property_map<PointVectorPair>()));
|
||||
}
|
||||
if (!success)
|
||||
{
|
||||
|
|
@ -324,10 +324,10 @@ int main(int argc, char * argv[])
|
|||
{
|
||||
std::ofstream stream(output_filename.c_str());
|
||||
if (!stream ||
|
||||
!CGAL::write_xyz_points_and_normals(stream,
|
||||
points.begin(), points.end(),
|
||||
CGAL::First_of_pair_property_map<PointVectorPair>(),
|
||||
CGAL::Second_of_pair_property_map<PointVectorPair>()))
|
||||
!CGAL::write_xyz_points(stream,
|
||||
points,
|
||||
CGAL::parameters::point_map(CGAL::First_of_pair_property_map<PointVectorPair>()).
|
||||
normal_map(CGAL::Second_of_pair_property_map<PointVectorPair>())))
|
||||
{
|
||||
std::cerr << "Error: cannot write file " << output_filename << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ int main(int argc, char*argv[])
|
|||
if (!stream ||
|
||||
!CGAL::read_xyz_points(stream,
|
||||
std::back_inserter(points),
|
||||
CGAL::First_of_pair_property_map<PointVectorPair>()))
|
||||
CGAL::parameters::point_map(CGAL::First_of_pair_property_map<PointVectorPair>())))
|
||||
{
|
||||
std::cerr << "Error: cannot read file " << fname<< std::endl;
|
||||
return EXIT_FAILURE;
|
||||
|
|
|
|||
|
|
@ -33,13 +33,10 @@ int main(int argc, char*argv[])
|
|||
std::vector<Point>(points).swap(points);
|
||||
|
||||
// Saves point set.
|
||||
// Note: write_xyz_points_and_normals() requires an output iterator
|
||||
// over points as well as property maps to access each
|
||||
// point position and normal.
|
||||
std::ofstream out((argc>2)?argv[2]:"Three_lady_copy.xyz");
|
||||
if (!out ||
|
||||
!CGAL::write_xyz_points(
|
||||
out, points.begin(), points.end()))
|
||||
out, points))
|
||||
{
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,31 +20,30 @@ int main(int argc, char*argv[])
|
|||
{
|
||||
const char* fname = (argc>1)?argv[1]:"data/oni.xyz";
|
||||
// Reads a .xyz point set file in points[].
|
||||
// Note: read_xyz_points_and_normals() requires an output iterator
|
||||
// Note: read_xyz_points() requires an output iterator
|
||||
// over points and as well as property maps to access each
|
||||
// point position and normal.
|
||||
std::vector<Pwn> points;
|
||||
std::ifstream in(fname);
|
||||
if (!in ||
|
||||
!CGAL::read_xyz_points_and_normals(
|
||||
!CGAL::read_xyz_points(
|
||||
in,std::back_inserter(points),
|
||||
CGAL::First_of_pair_property_map<Pwn>(),
|
||||
CGAL::Second_of_pair_property_map<Pwn>()))
|
||||
CGAL::parameters::point_map (CGAL::First_of_pair_property_map<Pwn>()).
|
||||
normal_map (CGAL::Second_of_pair_property_map<Pwn>())))
|
||||
{
|
||||
std::cerr << "Error: cannot read file " << fname << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
// Saves point set.
|
||||
// Note: write_xyz_points_and_normals() requires an output iterator
|
||||
// over points as well as property maps to access each
|
||||
// Note: write_xyz_points() requires property maps to access each
|
||||
// point position and normal.
|
||||
std::ofstream out("oni_copy.xyz");
|
||||
if (!out ||
|
||||
!CGAL::write_xyz_points_and_normals(
|
||||
out, points.begin(), points.end(),
|
||||
CGAL::First_of_pair_property_map<Pwn>(),
|
||||
CGAL::Second_of_pair_property_map<Pwn>()))
|
||||
!CGAL::write_xyz_points(
|
||||
out, points,
|
||||
CGAL::parameters::point_map(CGAL::First_of_pair_property_map<Pwn>()).
|
||||
normal_map(CGAL::Second_of_pair_property_map<Pwn>())))
|
||||
{
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ int main(int argc, char*argv[])
|
|||
std::ifstream stream(fname);
|
||||
if (!stream ||
|
||||
!CGAL::read_xyz_points(stream, std::back_inserter(points),
|
||||
CGAL::Identity_property_map<Point>()))
|
||||
CGAL::parameters::point_map(CGAL::Identity_property_map<Point>())))
|
||||
{
|
||||
std::cerr << "Error: cannot read file " << fname << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
|
|
|
|||
|
|
@ -34,10 +34,10 @@ int main (int argc, char** argv)
|
|||
std::ifstream stream(argc>1 ? argv[1] : "data/cube.pwn");
|
||||
|
||||
if (!stream ||
|
||||
!CGAL::read_xyz_points_and_normals(stream,
|
||||
!CGAL::read_xyz_points(stream,
|
||||
std::back_inserter(points),
|
||||
Point_map(),
|
||||
Normal_map()))
|
||||
CGAL::parameters::point_map(Point_map()).
|
||||
normal_map(Normal_map())))
|
||||
{
|
||||
std::cerr << "Error: cannot read file cube.pwn" << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
|
|
@ -68,8 +68,8 @@ int main (int argc, char** argv)
|
|||
<< " structured point(s) generated." << std::endl;
|
||||
|
||||
std::ofstream out ("out.pwn");
|
||||
CGAL::write_xyz_points_and_normals (out, structured_pts.begin(), structured_pts.end(),
|
||||
Point_map(), Normal_map());
|
||||
CGAL::write_xyz_points (out, structured_pts,
|
||||
CGAL::parameters::point_map(Point_map()).normal_map(Normal_map()));
|
||||
out.close();
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ int main(int argc, char** argv)
|
|||
|
||||
std::ofstream out(output_filename);
|
||||
if (!out || !CGAL::write_xyz_points(
|
||||
out, output.begin(), output.end()))
|
||||
out, output))
|
||||
{
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ int main(int, char**)
|
|||
CGAL::set_binary_mode(f); // The PLY file will be written in the binary format
|
||||
|
||||
CGAL::write_ply_points_with_properties
|
||||
(f, points.begin(), points.end(),
|
||||
(f, points,
|
||||
CGAL::make_ply_point_writer (Point_map()),
|
||||
std::make_tuple(Color_map(),
|
||||
CGAL::PLY_property<unsigned char>("red"),
|
||||
|
|
|
|||
|
|
@ -35,6 +35,9 @@
|
|||
#include <CGAL/point_set_processing_assertions.h>
|
||||
#include <CGAL/Kernel_traits.h>
|
||||
|
||||
#include <CGAL/boost/graph/named_function_params.h>
|
||||
#include <CGAL/boost/graph/named_params_helper.h>
|
||||
|
||||
#include <boost/version.hpp>
|
||||
#include <boost/cstdint.hpp>
|
||||
|
||||
|
|
@ -324,66 +327,64 @@ namespace internal {
|
|||
/// \endcond
|
||||
|
||||
|
||||
//===================================================================================
|
||||
/// \ingroup PkgPointSetProcessingIOLas
|
||||
/**
|
||||
\ingroup PkgPointSetProcessingIOLas
|
||||
|
||||
/// 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 `CGAL::cpp11::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`
|
||||
///
|
||||
/// @cgalRequiresCPP11
|
||||
///
|
||||
/// @sa `make_las_point_reader()`
|
||||
///
|
||||
/// @tparam OutputIteratorValueType type of objects that can be put in `OutputIterator`.
|
||||
/// It is default to `value_type_traits<OutputIterator>::%type` and can be omitted when the default is fine.
|
||||
/// @tparam OutputIterator iterator over output points.
|
||||
/// @tparam PropertyHandler handlers to recover properties.
|
||||
///
|
||||
/// @return `true` on success.
|
||||
Reads user-selected points properties from a .las or .laz stream.
|
||||
Potential additional properties are ignored.
|
||||
|
||||
// This variant requires all parameters.
|
||||
//-----------------------------------------------------------------------------------
|
||||
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 `CGAL::cpp11::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`
|
||||
|
||||
\cgalRequiresCPP11
|
||||
|
||||
\sa `make_las_point_reader()`
|
||||
|
||||
\tparam OutputIteratorValueType type of objects that can be put in `OutputIterator`.
|
||||
It is default to `value_type_traits<OutputIterator>::%type` and can be omitted when the default is fine.
|
||||
\tparam OutputIterator iterator over output points.
|
||||
\tparam PropertyHandler handlers to recover properties.
|
||||
|
||||
\return `true` on success.
|
||||
*/
|
||||
template <typename OutputIteratorValueType,
|
||||
typename OutputIterator,
|
||||
typename ... PropertyHandler>
|
||||
|
|
@ -427,77 +428,121 @@ bool read_las_points_with_properties (std::istream& stream,
|
|||
}
|
||||
/// \endcond
|
||||
|
||||
//===================================================================================
|
||||
/// \ingroup PkgPointSetProcessingIOLas
|
||||
/// Reads points (position only) from a .las or .laz stream.
|
||||
/// Potential additional properties are ignored.
|
||||
///
|
||||
/// @tparam OutputIteratorValueType type of objects that can be put in `OutputIterator`.
|
||||
/// It is default to `value_type_traits<OutputIterator>::%type` and can be omitted when the default is fine.
|
||||
/// @tparam OutputIterator iterator over output points.
|
||||
/// @tparam PointPMap is a model of `WritablePropertyMap` with value_type `CGAL::Point_3`.
|
||||
/// It can be omitted if the value type of `OutputIterator` is convertible to `CGAL::Point_3`.
|
||||
///
|
||||
/// @return `true` on success.
|
||||
///
|
||||
/// @cgalRequiresCPP11
|
||||
/**
|
||||
\ingroup PkgPointSetProcessingIOLas
|
||||
Reads points (position only) from a .las or .laz stream.
|
||||
Potential additional properties are ignored.
|
||||
|
||||
// This variant requires all parameters.
|
||||
//-----------------------------------------------------------------------------------
|
||||
\tparam OutputIteratorValueType type of objects that can be put in `OutputIterator`.
|
||||
It is default to `value_type_traits<OutputIterator>::%type` and can be omitted when the default is fine.
|
||||
\tparam OutputIterator iterator over output points.
|
||||
|
||||
\param stream input stream.
|
||||
\param output output iterator over points.
|
||||
|
||||
\param np optional sequence of \ref psp_namedparameters "Named Parameters" among the ones listed below.
|
||||
|
||||
\cgalNamedParamsBegin
|
||||
\cgalParamBegin{point_map} a model of `WritablePropertyMap` with value type `geom_traits::Point_3`.
|
||||
If this parameter is omitted, `CGAL::Identity_property_map<geom_traits::Point_3>` is used.\cgalParamEnd
|
||||
\cgalParamBegin{geom_traits} an instance of a geometric traits class, model of `Kernel`\cgalParamEnd
|
||||
\cgalNamedParamsEnd
|
||||
|
||||
\return true on success.
|
||||
|
||||
\cgalRequiresCPP11
|
||||
*/
|
||||
template < typename OutputIteratorValueType,
|
||||
typename OutputIterator,
|
||||
typename PointPMap >
|
||||
bool read_las_points(std::istream& stream, ///< input stream.
|
||||
OutputIterator output, ///< output iterator over points.
|
||||
PointPMap point_pmap) ///< property map: value_type of OutputIterator -> Point_3.
|
||||
#ifdef DOXYGEN_RUNNING
|
||||
typename NamedParameters
|
||||
#else
|
||||
typename CGAL_BGL_NP_TEMPLATE_PARAMETERS
|
||||
#endif
|
||||
>
|
||||
bool read_las_points(std::istream& stream,
|
||||
OutputIterator output,
|
||||
#ifdef DOXYGEN_RUNNING
|
||||
const NamedParameters& np)
|
||||
#else
|
||||
const CGAL_BGL_NP_CLASS& np)
|
||||
#endif
|
||||
{
|
||||
using boost::choose_param;
|
||||
|
||||
typedef Point_set_processing_3::Fake_point_range<OutputIteratorValueType> PointRange;
|
||||
|
||||
typedef typename Point_set_processing_3::GetPointMap<PointRange, CGAL_BGL_NP_CLASS>::type PointMap;
|
||||
PointMap point_map = choose_param(get_param(np, internal_np::point_map), PointMap());
|
||||
|
||||
return read_las_points_with_properties (stream, output,
|
||||
make_las_point_reader(point_pmap));
|
||||
make_las_point_reader (point_map));
|
||||
}
|
||||
|
||||
/// @cond SKIP_IN_MANUAL
|
||||
template < typename OutputIterator,
|
||||
typename PointPMap >
|
||||
/// \cond SKIP_IN_MANUAL
|
||||
// variant with default NP
|
||||
template <typename OutputIteratorValueType,
|
||||
typename OutputIterator>
|
||||
bool
|
||||
read_las_points(
|
||||
std::istream& stream, ///< input stream.
|
||||
OutputIterator output) ///< output iterator over points.
|
||||
{
|
||||
return read_las_points<OutputIteratorValueType>
|
||||
(stream, output, CGAL::parameters::all_default());
|
||||
}
|
||||
|
||||
// variant with default output iterator value type
|
||||
template <typename OutputIterator,
|
||||
typename CGAL_BGL_NP_TEMPLATE_PARAMETERS>
|
||||
bool
|
||||
read_las_points(
|
||||
std::istream& stream, ///< input stream.
|
||||
OutputIterator output,
|
||||
const CGAL_BGL_NP_CLASS& np)
|
||||
{
|
||||
return read_las_points<typename value_type_traits<OutputIterator>::type>
|
||||
(stream, output, np);
|
||||
}
|
||||
|
||||
// variant with default NP and output iterator value type
|
||||
template <typename OutputIterator>
|
||||
bool
|
||||
read_las_points(
|
||||
std::istream& stream, ///< input stream.
|
||||
OutputIterator output)
|
||||
{
|
||||
return read_las_points<typename value_type_traits<OutputIterator>::type>
|
||||
(stream, output, CGAL::parameters::all_default());
|
||||
}
|
||||
|
||||
// deprecated API
|
||||
template < typename OutputIteratorValueType,
|
||||
typename OutputIterator,
|
||||
typename PointMap >
|
||||
bool read_las_points(std::istream& stream, ///< input stream.
|
||||
OutputIterator output, ///< output iterator over points.
|
||||
PointPMap point_pmap) ///< property map: value_type of OutputIterator -> Point_3.
|
||||
PointMap point_map) ///< property map: value_type of OutputIterator -> Point_3.
|
||||
{
|
||||
// just deduce value_type of OutputIterator
|
||||
return read_las_points
|
||||
<typename value_type_traits<OutputIterator>::type>(stream,
|
||||
output,
|
||||
point_pmap);
|
||||
CGAL_POINT_SET_PROCESSING_DEPRECATED_V1_API("read_las_points()");
|
||||
return read_las_points<OutputIteratorValueType>
|
||||
(stream, output,
|
||||
CGAL::parameters::point_map (point_map));
|
||||
}
|
||||
//-----------------------------------------------------------------------------------
|
||||
/// @endcond
|
||||
|
||||
/// @cond SKIP_IN_MANUAL
|
||||
// This variant creates a default point property map = Identity_property_map.
|
||||
//-----------------------------------------------------------------------------------
|
||||
template < typename OutputIteratorValueType,
|
||||
typename OutputIterator >
|
||||
// deprecated API
|
||||
template < typename OutputIterator,
|
||||
typename PointMap >
|
||||
bool read_las_points(std::istream& stream, ///< input stream.
|
||||
OutputIterator output) ///< output iterator over points.
|
||||
OutputIterator output, ///< output iterator over points.
|
||||
PointMap point_map) ///< property map: value_type of OutputIterator -> Point_3.
|
||||
{
|
||||
return read_las_points
|
||||
<OutputIteratorValueType>(stream,
|
||||
output,
|
||||
make_identity_property_map(OutputIteratorValueType())
|
||||
);
|
||||
CGAL_POINT_SET_PROCESSING_DEPRECATED_V1_API("read_las_points()");
|
||||
return read_las_points<typename value_type_traits<OutputIterator>::type>
|
||||
(stream, output,
|
||||
CGAL::parameters::point_map (point_map));
|
||||
}
|
||||
|
||||
template < typename OutputIterator>
|
||||
bool read_las_points(std::istream& stream, ///< input stream.
|
||||
OutputIterator output) ///< output iterator over points.
|
||||
{
|
||||
// just deduce value_type of OutputIterator
|
||||
return read_las_points
|
||||
<typename value_type_traits<OutputIterator>::type>(stream,
|
||||
output);
|
||||
}
|
||||
//-----------------------------------------------------------------------------------
|
||||
|
||||
/// @endcond
|
||||
/// \endcond
|
||||
|
||||
|
||||
} //namespace CGAL
|
||||
|
|
|
|||
|
|
@ -31,6 +31,9 @@
|
|||
#include <CGAL/point_set_processing_assertions.h>
|
||||
#include <CGAL/Kernel_traits.h>
|
||||
|
||||
#include <CGAL/boost/graph/named_function_params.h>
|
||||
#include <CGAL/boost/graph/named_params_helper.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
|
|
@ -38,40 +41,65 @@
|
|||
namespace CGAL {
|
||||
|
||||
|
||||
//===================================================================================
|
||||
/// \ingroup PkgPointSetProcessingIO
|
||||
/// Reads points (positions + normals, if available) from a .off ASCII stream.
|
||||
/// The function expects for each point a line with the x y z position,
|
||||
/// optionally followed by the nx ny nz normal.
|
||||
/// Faces are ignored.
|
||||
///
|
||||
/// @tparam OutputIteratorValueType type of objects that can be put in `OutputIterator`.
|
||||
/// It is default to `value_type_traits<OutputIterator>::%type` and can be omitted when the default is fine.
|
||||
/// @tparam OutputIterator iterator over output points.
|
||||
/// @tparam PointPMap is a model of `WritablePropertyMap` with value type `Point_3<Kernel>`.
|
||||
/// It can be omitted if the value type of `OutputIterator` is convertible to `Point_3<Kernel>`.
|
||||
/// @tparam NormalPMap is a model of `WritablePropertyMap` with value type `Vector_3<Kernel>`.
|
||||
/// @tparam Kernel Geometric traits class.
|
||||
/// It can be omitted and deduced automatically from the value type of `PointPMap`.
|
||||
///
|
||||
/// @return true on success.
|
||||
/**
|
||||
\ingroup PkgPointSetProcessingIO
|
||||
Reads points (positions + normals, if available) from a .off ASCII stream.
|
||||
The function expects for each point a line with the x y z position,
|
||||
optionally followed by the nx ny nz normal.
|
||||
Faces are ignored.
|
||||
|
||||
// This variant requires all parameters.
|
||||
//-----------------------------------------------------------------------------------
|
||||
\tparam OutputIteratorValueType type of objects that can be put in `OutputIterator`.
|
||||
It is default to `value_type_traits<OutputIterator>::%type` and can be omitted when the default is fine.
|
||||
\tparam OutputIterator iterator over output points.
|
||||
|
||||
\param stream input stream.
|
||||
\param output output iterator over points.
|
||||
\param np optional sequence of \ref psp_namedparameters "Named Parameters" among the ones listed below.
|
||||
|
||||
\cgalNamedParamsBegin
|
||||
\cgalParamBegin{point_map} a model of `WritablePropertyMap` with value type `geom_traits::Point_3`.
|
||||
If this parameter is omitted, `CGAL::Identity_property_map<geom_traits::Point_3>` is used.\cgalParamEnd
|
||||
\cgalParamBegin{normal_map} a model of `ReadWritePropertyMap` with value type
|
||||
`geom_traits::Vector_3`. If this parameter is omitted, normals in the input stream are
|
||||
ignored.\cgalParamEnd
|
||||
\cgalParamBegin{geom_traits} an instance of a geometric traits class, model of `Kernel`\cgalParamEnd
|
||||
\cgalNamedParamsEnd
|
||||
|
||||
\return true on success.
|
||||
*/
|
||||
template <typename OutputIteratorValueType,
|
||||
typename OutputIterator,
|
||||
typename PointPMap,
|
||||
typename NormalPMap,
|
||||
typename Kernel
|
||||
#ifdef DOXYGEN_RUNNING
|
||||
typename NamedParameters
|
||||
#else
|
||||
typename CGAL_BGL_NP_TEMPLATE_PARAMETERS
|
||||
#endif
|
||||
>
|
||||
bool
|
||||
read_off_points_and_normals(
|
||||
std::istream& stream, ///< input stream.
|
||||
OutputIterator output, ///< output iterator over points.
|
||||
PointPMap point_pmap, ///< property map: value_type of OutputIterator -> Point_3.
|
||||
NormalPMap normal_pmap, ///< property map: value_type of OutputIterator -> Vector_3.
|
||||
const Kernel& /*kernel*/) ///< geometric traits.
|
||||
read_off_points(
|
||||
std::istream& stream,
|
||||
OutputIterator output,
|
||||
#ifdef DOXYGEN_RUNNING
|
||||
const NamedParameters& np)
|
||||
#else
|
||||
const CGAL_BGL_NP_CLASS& np)
|
||||
#endif
|
||||
{
|
||||
using boost::choose_param;
|
||||
|
||||
typedef Point_set_processing_3::Fake_point_range<OutputIteratorValueType> PointRange;
|
||||
|
||||
// basic geometric types
|
||||
typedef typename Point_set_processing_3::GetPointMap<PointRange, CGAL_BGL_NP_CLASS>::type PointMap;
|
||||
typedef typename Point_set_processing_3::GetNormalMap<PointRange, CGAL_BGL_NP_CLASS>::type NormalMap;
|
||||
typedef typename Point_set_processing_3::GetK<PointRange, CGAL_BGL_NP_CLASS>::Kernel Kernel;
|
||||
|
||||
bool has_normals = !(boost::is_same<NormalMap,
|
||||
typename Point_set_processing_3::GetNormalMap<PointRange, CGAL_BGL_NP_CLASS>::NoMap>::value);
|
||||
|
||||
PointMap point_map = choose_param(get_param(np, internal_np::point_map), PointMap());
|
||||
NormalMap normal_map = choose_param(get_param(np, internal_np::normal_map), NormalMap());
|
||||
|
||||
// value_type_traits is a workaround as back_insert_iterator's value_type is void
|
||||
// typedef typename value_type_traits<OutputIterator>::type Enriched_point;
|
||||
typedef OutputIteratorValueType Enriched_point;
|
||||
|
|
@ -147,8 +175,9 @@ read_off_points_and_normals(
|
|||
}
|
||||
}
|
||||
Enriched_point pwn;
|
||||
put(point_pmap, pwn, point); // point_pmap[&pwn] = point
|
||||
put(normal_pmap, pwn, normal); // normal_pmap[&pwn] = normal
|
||||
put(point_map, pwn, point); // point_map[&pwn] = point
|
||||
if (has_normals)
|
||||
put(normal_map, pwn, normal); // normal_map[&pwn] = normal
|
||||
*output++ = pwn;
|
||||
pointsRead++;
|
||||
}
|
||||
|
|
@ -160,7 +189,67 @@ read_off_points_and_normals(
|
|||
return true;
|
||||
}
|
||||
|
||||
/// @cond SKIP_IN_MANUAL
|
||||
/// \cond SKIP_IN_MANUAL
|
||||
// variant with default NP
|
||||
template <typename OutputIteratorValueType,
|
||||
typename OutputIterator>
|
||||
bool
|
||||
read_off_points(
|
||||
std::istream& stream, ///< input stream.
|
||||
OutputIterator output) ///< output iterator over points.
|
||||
{
|
||||
return read_off_points<OutputIteratorValueType>
|
||||
(stream, output, CGAL::parameters::all_default());
|
||||
}
|
||||
|
||||
// variant with default output iterator value type
|
||||
template <typename OutputIterator,
|
||||
typename CGAL_BGL_NP_TEMPLATE_PARAMETERS>
|
||||
bool
|
||||
read_off_points(
|
||||
std::istream& stream, ///< input stream.
|
||||
OutputIterator output,
|
||||
const CGAL_BGL_NP_CLASS& np)
|
||||
{
|
||||
return read_off_points<typename value_type_traits<OutputIterator>::type>
|
||||
(stream, output, np);
|
||||
}
|
||||
|
||||
// variant with default NP and output iterator value type
|
||||
template <typename OutputIterator>
|
||||
bool
|
||||
read_off_points(
|
||||
std::istream& stream, ///< input stream.
|
||||
OutputIterator output)
|
||||
{
|
||||
return read_off_points<typename value_type_traits<OutputIterator>::type>
|
||||
(stream, output, CGAL::parameters::all_default());
|
||||
}
|
||||
|
||||
// deprecated API
|
||||
template <typename OutputIteratorValueType,
|
||||
typename OutputIterator,
|
||||
typename PointPMap,
|
||||
typename NormalPMap,
|
||||
typename Kernel
|
||||
>
|
||||
bool
|
||||
read_off_points_and_normals(
|
||||
std::istream& stream, ///< input stream.
|
||||
OutputIterator output, ///< output iterator over points.
|
||||
PointPMap point_map, ///< property map: value_type of OutputIterator -> Point_3.
|
||||
NormalPMap normal_map, ///< property map: value_type of OutputIterator -> Vector_3.
|
||||
const Kernel& /*kernel*/) ///< geometric traits.
|
||||
{
|
||||
CGAL_POINT_SET_PROCESSING_DEPRECATED_V1_API("read_off_points_and_normals()");
|
||||
return read_off_points<OutputIteratorValueType>
|
||||
(stream, output,
|
||||
CGAL::parameters::point_map (point_map).
|
||||
normal_map (normal_map).
|
||||
geom_traits (Kernel()));
|
||||
}
|
||||
|
||||
// deprecated API
|
||||
template <typename OutputIterator,
|
||||
typename PointPMap,
|
||||
typename NormalPMap,
|
||||
|
|
@ -170,25 +259,19 @@ bool
|
|||
read_off_points_and_normals(
|
||||
std::istream& stream, ///< input stream.
|
||||
OutputIterator output, ///< output iterator over points.
|
||||
PointPMap point_pmap, ///< property map: value_type of OutputIterator -> Point_3.
|
||||
NormalPMap normal_pmap, ///< property map: value_type of OutputIterator -> Vector_3.
|
||||
PointPMap point_map, ///< property map: value_type of OutputIterator -> Point_3.
|
||||
NormalPMap normal_map, ///< property map: value_type of OutputIterator -> Vector_3.
|
||||
const Kernel& kernel) ///< geometric traits.
|
||||
{
|
||||
// just deduce value_type of OutputIterator
|
||||
return read_off_points_and_normals
|
||||
<typename value_type_traits<OutputIterator>::type>(
|
||||
stream,
|
||||
output,
|
||||
point_pmap,
|
||||
normal_pmap,
|
||||
kernel);
|
||||
CGAL_POINT_SET_PROCESSING_DEPRECATED_V1_API("read_off_points_and_normals()");
|
||||
return read_off_points<typename value_type_traits<OutputIterator>::type>
|
||||
(stream, output,
|
||||
CGAL::parameters::point_map (point_map).
|
||||
normal_map (normal_map).
|
||||
geom_traits (kernel));
|
||||
}
|
||||
//-----------------------------------------------------------------------------------
|
||||
/// @endcond
|
||||
|
||||
/// @cond SKIP_IN_MANUAL
|
||||
// This variant deduces the kernel from the point property map.
|
||||
//-----------------------------------------------------------------------------------
|
||||
// deprecated API
|
||||
template <typename OutputIteratorValueType,
|
||||
typename OutputIterator,
|
||||
typename PointPMap,
|
||||
|
|
@ -198,20 +281,17 @@ bool
|
|||
read_off_points_and_normals(
|
||||
std::istream& stream, ///< input stream.
|
||||
OutputIterator output, ///< output iterator over points.
|
||||
PointPMap point_pmap, ///< property map: value_type of OutputIterator -> Point_3.
|
||||
NormalPMap normal_pmap) ///< property map: value_type of OutputIterator -> Vector_3.
|
||||
PointPMap point_map, ///< property map: value_type of OutputIterator -> Point_3.
|
||||
NormalPMap normal_map) ///< property map: value_type of OutputIterator -> Vector_3.
|
||||
{
|
||||
typedef typename boost::property_traits<PointPMap>::value_type Point;
|
||||
typedef typename Kernel_traits<Point>::Kernel Kernel;
|
||||
return read_off_points_and_normals
|
||||
<OutputIteratorValueType>(
|
||||
stream,
|
||||
output,
|
||||
point_pmap,
|
||||
normal_pmap,
|
||||
Kernel());
|
||||
CGAL_POINT_SET_PROCESSING_DEPRECATED_V1_API("read_off_points_and_normals()");
|
||||
return read_off_points<OutputIteratorValueType>
|
||||
(stream, output,
|
||||
CGAL::parameters::point_map (point_map).
|
||||
normal_map (normal_map));
|
||||
}
|
||||
|
||||
// deprecated API
|
||||
template <typename OutputIterator,
|
||||
typename PointPMap,
|
||||
typename NormalPMap
|
||||
|
|
@ -220,23 +300,17 @@ bool
|
|||
read_off_points_and_normals(
|
||||
std::istream& stream, ///< input stream.
|
||||
OutputIterator output, ///< output iterator over points.
|
||||
PointPMap point_pmap, ///< property map: value_type of OutputIterator -> Point_3.
|
||||
NormalPMap normal_pmap) ///< property map: value_type of OutputIterator -> Vector_3.
|
||||
PointPMap point_map, ///< property map: value_type of OutputIterator -> Point_3.
|
||||
NormalPMap normal_map) ///< property map: value_type of OutputIterator -> Vector_3.
|
||||
{
|
||||
// just deduce value_type of OutputIterator
|
||||
return read_off_points_and_normals
|
||||
<typename value_type_traits<OutputIterator>::type>(
|
||||
stream,
|
||||
output,
|
||||
point_pmap,
|
||||
normal_pmap);
|
||||
CGAL_POINT_SET_PROCESSING_DEPRECATED_V1_API("read_off_points_and_normals()");
|
||||
return read_off_points<typename value_type_traits<OutputIterator>::type>
|
||||
(stream, output,
|
||||
CGAL::parameters::point_map (point_map).
|
||||
normal_map (normal_map));
|
||||
}
|
||||
//-----------------------------------------------------------------------------------
|
||||
/// @endcond
|
||||
|
||||
/// @cond SKIP_IN_MANUAL
|
||||
// This variant creates a default point property map = Identity_property_map.
|
||||
//-----------------------------------------------------------------------------------
|
||||
// deprecated API
|
||||
template <typename OutputIteratorValueType,
|
||||
typename OutputIterator,
|
||||
typename NormalPMap
|
||||
|
|
@ -245,16 +319,15 @@ bool
|
|||
read_off_points_and_normals(
|
||||
std::istream& stream, ///< input stream.
|
||||
OutputIterator output, ///< output iterator over points.
|
||||
NormalPMap normal_pmap) ///< property map: value_type of OutputIterator -> Vector_3.
|
||||
NormalPMap normal_map) ///< property map: value_type of OutputIterator -> Vector_3.
|
||||
{
|
||||
return read_off_points_and_normals
|
||||
<OutputIteratorValueType>(
|
||||
stream,
|
||||
output,
|
||||
make_identity_property_map(OutputIteratorValueType()),
|
||||
normal_pmap);
|
||||
CGAL_POINT_SET_PROCESSING_DEPRECATED_V1_API("read_off_points_and_normals()");
|
||||
return read_off_points<OutputIteratorValueType>
|
||||
(stream, output,
|
||||
CGAL::parameters::normal_map (normal_map));
|
||||
}
|
||||
|
||||
// deprecated API
|
||||
template <typename OutputIterator,
|
||||
typename NormalPMap
|
||||
>
|
||||
|
|
@ -262,38 +335,15 @@ bool
|
|||
read_off_points_and_normals(
|
||||
std::istream& stream, ///< input stream.
|
||||
OutputIterator output, ///< output iterator over points.
|
||||
NormalPMap normal_pmap) ///< property map: value_type of OutputIterator -> Vector_3.
|
||||
NormalPMap normal_map) ///< property map: value_type of OutputIterator -> Vector_3.
|
||||
{
|
||||
// just deduce value_type of OutputIterator
|
||||
return read_off_points_and_normals
|
||||
<typename value_type_traits<OutputIterator>::type>(
|
||||
stream,
|
||||
output,
|
||||
normal_pmap);
|
||||
CGAL_POINT_SET_PROCESSING_DEPRECATED_V1_API("read_off_points_and_normals()");
|
||||
return read_off_points<typename value_type_traits<OutputIterator>::type>
|
||||
(stream, output,
|
||||
CGAL::parameters::normal_map (normal_map));
|
||||
}
|
||||
//-----------------------------------------------------------------------------------
|
||||
/// @endcond
|
||||
|
||||
|
||||
//===================================================================================
|
||||
/// \ingroup PkgPointSetProcessingIO
|
||||
/// Reads points (position only) from a .off ASCII stream.
|
||||
/// The function expects for each point a line with the x y z position.
|
||||
/// If the position is followed by the nx ny nz normal, then the normal will be ignored.
|
||||
/// Faces are ignored.
|
||||
///
|
||||
/// @tparam OutputIteratorValueType type of objects that can be put in `OutputIterator`.
|
||||
/// It is default to `value_type_traits<OutputIterator>::%type` and can be omitted when the default is fine.
|
||||
/// @tparam OutputIterator iterator over output points.
|
||||
/// @tparam PointPMap is a model of `WritablePropertyMap` with value_type `Point_3<Kernel>`.
|
||||
/// It can be omitted if the value type of `OutputIterator` is convertible to `Point_3<Kernel>`.
|
||||
/// @tparam Kernel Geometric traits class.
|
||||
/// It can be omitted and deduced automatically from the value type of `PointPMap`.
|
||||
///
|
||||
/// @return `true` on success.
|
||||
|
||||
// This variant requires all parameters.
|
||||
//-----------------------------------------------------------------------------------
|
||||
// deprecated API
|
||||
template <typename OutputIteratorValueType,
|
||||
typename OutputIterator,
|
||||
typename PointPMap,
|
||||
|
|
@ -303,20 +353,17 @@ bool
|
|||
read_off_points(
|
||||
std::istream& stream, ///< input stream.
|
||||
OutputIterator output, ///< output iterator over points.
|
||||
PointPMap point_pmap, ///< property map: value_type of OutputIterator -> Point_3.
|
||||
PointPMap point_map, ///< property map: value_type of OutputIterator -> Point_3.
|
||||
const Kernel& kernel) ///< geometric traits.
|
||||
{
|
||||
// Calls read_off_points_and_normals() with a normal property map = boost::dummy_property_map
|
||||
return read_off_points_and_normals
|
||||
<OutputIteratorValueType>(
|
||||
stream,
|
||||
output,
|
||||
point_pmap,
|
||||
boost::dummy_property_map(),
|
||||
kernel);
|
||||
CGAL_POINT_SET_PROCESSING_DEPRECATED_V1_API("read_off_points()");
|
||||
return read_off_points<OutputIteratorValueType>
|
||||
(stream, output,
|
||||
CGAL::parameters::point_map (point_map).
|
||||
geom_traits (kernel));
|
||||
}
|
||||
|
||||
/// @cond SKIP_IN_MANUAL
|
||||
// deprecated API
|
||||
template <typename OutputIterator,
|
||||
typename PointPMap,
|
||||
typename Kernel
|
||||
|
|
@ -325,23 +372,17 @@ bool
|
|||
read_off_points(
|
||||
std::istream& stream, ///< input stream.
|
||||
OutputIterator output, ///< output iterator over points.
|
||||
PointPMap point_pmap, ///< property map: value_type of OutputIterator -> Point_3.
|
||||
PointPMap point_map, ///< property map: value_type of OutputIterator -> Point_3.
|
||||
const Kernel& kernel) ///< geometric traits.
|
||||
{
|
||||
// just deduce value_type of OutputIterator
|
||||
return read_off_points
|
||||
<typename value_type_traits<OutputIterator>::type>(
|
||||
stream,
|
||||
output,
|
||||
point_pmap,
|
||||
kernel);
|
||||
CGAL_POINT_SET_PROCESSING_DEPRECATED_V1_API("read_off_points()");
|
||||
return read_off_points<typename value_type_traits<OutputIterator>::type>
|
||||
(stream, output,
|
||||
CGAL::parameters::point_map (point_map).
|
||||
geom_traits (kernel));
|
||||
}
|
||||
//-----------------------------------------------------------------------------------
|
||||
/// @endcond
|
||||
|
||||
/// @cond SKIP_IN_MANUAL
|
||||
// This variant deduces the kernel from the point property map.
|
||||
//-----------------------------------------------------------------------------------
|
||||
// deprecated API
|
||||
template <typename OutputIteratorValueType,
|
||||
typename OutputIterator,
|
||||
typename PointPMap
|
||||
|
|
@ -350,18 +391,15 @@ bool
|
|||
read_off_points(
|
||||
std::istream& stream, ///< input stream.
|
||||
OutputIterator output, ///< output iterator over points.
|
||||
PointPMap point_pmap) ///< property map: value_type of OutputIterator -> Point_3.
|
||||
PointPMap point_map) ///< property map: value_type of OutputIterator -> Point_3.
|
||||
{
|
||||
typedef typename boost::property_traits<PointPMap>::value_type Point;
|
||||
typedef typename Kernel_traits<Point>::Kernel Kernel;
|
||||
return read_off_points
|
||||
<OutputIteratorValueType>(
|
||||
stream,
|
||||
output,
|
||||
point_pmap,
|
||||
Kernel());
|
||||
CGAL_POINT_SET_PROCESSING_DEPRECATED_V1_API("read_off_points()");
|
||||
return read_off_points<OutputIteratorValueType>
|
||||
(stream, output,
|
||||
CGAL::parameters::point_map (point_map));
|
||||
}
|
||||
|
||||
// deprecated API
|
||||
template <typename OutputIterator,
|
||||
typename PointPMap
|
||||
>
|
||||
|
|
@ -369,53 +407,15 @@ bool
|
|||
read_off_points(
|
||||
std::istream& stream, ///< input stream.
|
||||
OutputIterator output, ///< output iterator over points.
|
||||
PointPMap point_pmap) ///< property map: value_type of OutputIterator -> Point_3.
|
||||
PointPMap point_map) ///< property map: value_type of OutputIterator -> Point_3.
|
||||
{
|
||||
// just deduce value_type of OutputIterator
|
||||
return read_off_points
|
||||
<typename value_type_traits<OutputIterator>::type>(
|
||||
stream,
|
||||
output,
|
||||
point_pmap);
|
||||
}
|
||||
//-----------------------------------------------------------------------------------
|
||||
/// @endcond
|
||||
|
||||
/// @cond SKIP_IN_MANUAL
|
||||
// This variant creates a default point property map = Identity_property_map.
|
||||
//-----------------------------------------------------------------------------------
|
||||
template <typename OutputIteratorValueType,
|
||||
typename OutputIterator
|
||||
>
|
||||
bool
|
||||
read_off_points(
|
||||
std::istream& stream, ///< input stream.
|
||||
OutputIterator output) ///< output iterator over points.
|
||||
{
|
||||
return read_off_points
|
||||
<OutputIteratorValueType>(
|
||||
stream,
|
||||
output,
|
||||
make_identity_property_map(OutputIteratorValueType())
|
||||
);
|
||||
CGAL_POINT_SET_PROCESSING_DEPRECATED_V1_API("read_off_points()");
|
||||
return read_off_points<typename value_type_traits<OutputIterator>::type>
|
||||
(stream, output,
|
||||
CGAL::parameters::point_map (point_map));
|
||||
}
|
||||
|
||||
template <typename OutputIterator
|
||||
>
|
||||
bool
|
||||
read_off_points(
|
||||
std::istream& stream, ///< input stream.
|
||||
OutputIterator output) ///< output iterator over points.
|
||||
{
|
||||
// just deduce value_type of OutputIterator
|
||||
return read_off_points
|
||||
<typename value_type_traits<OutputIterator>::type>(
|
||||
stream,
|
||||
output);
|
||||
}
|
||||
//-----------------------------------------------------------------------------------
|
||||
|
||||
/// @endcond
|
||||
/// \endcond
|
||||
|
||||
|
||||
} //namespace CGAL
|
||||
|
|
|
|||
|
|
@ -36,6 +36,9 @@
|
|||
#include <CGAL/Kernel_traits.h>
|
||||
#include <CGAL/IO/io.h>
|
||||
|
||||
#include <CGAL/boost/graph/named_function_params.h>
|
||||
#include <CGAL/boost/graph/named_params_helper.h>
|
||||
|
||||
#include <boost/version.hpp>
|
||||
#include <boost/cstdint.hpp>
|
||||
|
||||
|
|
@ -659,42 +662,40 @@ namespace internal {
|
|||
/// \endcond
|
||||
|
||||
|
||||
//===================================================================================
|
||||
/// \ingroup PkgPointSetProcessingIOPly
|
||||
/*
|
||||
\ingroup PkgPointSetProcessingIOPly
|
||||
|
||||
/// 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 `CGAL::cpp11::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`.
|
||||
///
|
||||
/// @sa `make_ply_point_reader()`
|
||||
/// @sa `make_ply_normal_reader()`
|
||||
///
|
||||
/// @cgalRequiresCPP11
|
||||
///
|
||||
/// @tparam OutputIteratorValueType type of objects that can be put in `OutputIterator`.
|
||||
/// It is default to `value_type_traits<OutputIterator>::%type` and can be omitted when the default is fine.
|
||||
/// @tparam OutputIterator iterator over output points.
|
||||
/// @tparam PropertyHandler handlers to recover properties.
|
||||
///
|
||||
/// @return `true` on success.
|
||||
Reads user-selected points properties from a .ply stream (ASCII or
|
||||
binary).
|
||||
Potential additional point properties and faces are ignored.
|
||||
|
||||
// This variant requires all parameters.
|
||||
//-----------------------------------------------------------------------------------
|
||||
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 `CGAL::cpp11::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`.
|
||||
|
||||
\sa `make_ply_point_reader()`
|
||||
\sa `make_ply_normal_reader()`
|
||||
|
||||
\cgalRequiresCPP11
|
||||
|
||||
\tparam OutputIteratorValueType type of objects that can be put in `OutputIterator`.
|
||||
It is default to `value_type_traits<OutputIterator>::%type` and can be omitted when the default is fine.
|
||||
\tparam OutputIterator iterator over output points.
|
||||
\tparam PropertyHandler handlers to recover properties.
|
||||
|
||||
\return `true` on success.
|
||||
*/
|
||||
template <typename OutputIteratorValueType,
|
||||
typename OutputIterator,
|
||||
typename ... PropertyHandler>
|
||||
|
|
@ -749,164 +750,199 @@ bool read_ply_points_with_properties (std::istream& stream,
|
|||
}
|
||||
/// \endcond
|
||||
|
||||
//===================================================================================
|
||||
/// \ingroup PkgPointSetProcessingIOPly
|
||||
/// Reads points (positions + normals, if available) from a .ply
|
||||
/// stream (ASCII or binary).
|
||||
/// Potential additional point properties and faces are ignored.
|
||||
///
|
||||
/// @tparam OutputIteratorValueType type of objects that can be put in `OutputIterator`.
|
||||
/// It is default to `value_type_traits<OutputIterator>::%type` and can be omitted when the default is fine.
|
||||
/// @tparam OutputIterator iterator over output points.
|
||||
/// @tparam PointPMap is a model of `WritablePropertyMap` with value type `CGAL::Point_3`.
|
||||
/// @tparam NormalPMap is a model of `WritablePropertyMap` with value type `CGAL::Vector_3`.
|
||||
///
|
||||
/// @return `true` on success.
|
||||
///
|
||||
/// @cgalRequiresCPP11
|
||||
/**
|
||||
\ingroup PkgPointSetProcessingIOPly
|
||||
Reads points (positions + normals, if available) from a .ply
|
||||
stream (ASCII or binary).
|
||||
Potential additional point properties and faces are ignored.
|
||||
|
||||
// This variant requires all parameters.
|
||||
//-----------------------------------------------------------------------------------
|
||||
\tparam OutputIteratorValueType type of objects that can be put in `OutputIterator`.
|
||||
It is default to `value_type_traits<OutputIterator>::%type` and can be omitted when the default is fine.
|
||||
\tparam OutputIterator iterator over output points.
|
||||
|
||||
\param stream input stream.
|
||||
\param output output iterator over points.
|
||||
\param np optional sequence of \ref psp_namedparameters "Named Parameters" among the ones listed below.
|
||||
|
||||
\cgalNamedParamsBegin
|
||||
\cgalParamBegin{point_map} a model of `WritablePropertyMap` with value type `geom_traits::Point_3`.
|
||||
If this parameter is omitted, `CGAL::Identity_property_map<geom_traits::Point_3>` is used.\cgalParamEnd
|
||||
\cgalParamBegin{normal_map} a model of `ReadWritePropertyMap` with value type
|
||||
`geom_traits::Vector_3`. If this parameter is omitted, normals in the input stream are
|
||||
ignored.\cgalParamEnd
|
||||
\cgalParamBegin{geom_traits} an instance of a geometric traits class, model of `Kernel`\cgalParamEnd
|
||||
\cgalNamedParamsEnd
|
||||
|
||||
\return true on success.
|
||||
|
||||
\cgalRequiresCPP11
|
||||
*/
|
||||
template < typename OutputIteratorValueType,
|
||||
typename OutputIterator,
|
||||
typename PointPMap,
|
||||
typename NormalPMap >
|
||||
bool read_ply_points_and_normals(std::istream& stream, ///< input stream.
|
||||
OutputIterator output, ///< output iterator over points.
|
||||
PointPMap point_pmap, ///< property map: value_type of OutputIterator -> Point_3.
|
||||
NormalPMap normal_pmap) ///< property map: value_type of OutputIterator -> Vector_3.
|
||||
#ifdef DOXYGEN_RUNNING
|
||||
typename NamedParameters
|
||||
#else
|
||||
typename CGAL_BGL_NP_TEMPLATE_PARAMETERS
|
||||
#endif
|
||||
>
|
||||
bool read_ply_points(std::istream& stream,
|
||||
OutputIterator output,
|
||||
#ifdef DOXYGEN_RUNNING
|
||||
const NamedParameters& np)
|
||||
#else
|
||||
const CGAL_BGL_NP_CLASS& np)
|
||||
#endif
|
||||
{
|
||||
using boost::choose_param;
|
||||
|
||||
typedef Point_set_processing_3::Fake_point_range<OutputIteratorValueType> PointRange;
|
||||
|
||||
// basic geometric types
|
||||
typedef typename Point_set_processing_3::GetPointMap<PointRange, CGAL_BGL_NP_CLASS>::type PointMap;
|
||||
typedef typename Point_set_processing_3::GetNormalMap<PointRange, CGAL_BGL_NP_CLASS>::type NormalMap;
|
||||
|
||||
bool has_normals = !(boost::is_same<NormalMap,
|
||||
typename Point_set_processing_3::GetNormalMap<PointRange, CGAL_BGL_NP_CLASS>::NoMap>::value);
|
||||
|
||||
PointMap point_map = choose_param(get_param(np, internal_np::point_map), PointMap());
|
||||
NormalMap normal_map = choose_param(get_param(np, internal_np::normal_map), NormalMap());
|
||||
|
||||
if (has_normals)
|
||||
return read_ply_points_with_properties (stream, output,
|
||||
make_ply_point_reader (point_map),
|
||||
make_ply_normal_reader (normal_map));
|
||||
// else
|
||||
return read_ply_points_with_properties (stream, output,
|
||||
make_ply_point_reader (point_pmap),
|
||||
make_ply_normal_reader (normal_pmap));
|
||||
make_ply_point_reader (point_map));
|
||||
}
|
||||
|
||||
/// @cond SKIP_IN_MANUAL
|
||||
template < typename OutputIterator,
|
||||
typename PointPMap,
|
||||
typename NormalPMap >
|
||||
bool read_ply_points_and_normals(std::istream& stream, ///< input stream.
|
||||
OutputIterator output, ///< output iterator over points.
|
||||
PointPMap point_pmap, ///< property map: value_type of OutputIterator -> Point_3.
|
||||
NormalPMap normal_pmap) ///< property map: value_type of OutputIterator -> Vector_3.
|
||||
|
||||
/// \cond SKIP_IN_MANUAL
|
||||
// variant with default NP
|
||||
template <typename OutputIteratorValueType,
|
||||
typename OutputIterator>
|
||||
bool
|
||||
read_ply_points(
|
||||
std::istream& stream, ///< input stream.
|
||||
OutputIterator output) ///< output iterator over points.
|
||||
{
|
||||
// just deduce value_type of OutputIterator
|
||||
return read_ply_points_and_normals
|
||||
<typename value_type_traits<OutputIterator>::type>(stream,
|
||||
output,
|
||||
point_pmap,
|
||||
normal_pmap);
|
||||
return read_ply_points<OutputIteratorValueType>
|
||||
(stream, output, CGAL::parameters::all_default());
|
||||
}
|
||||
//-----------------------------------------------------------------------------------
|
||||
/// @endcond
|
||||
|
||||
// variant with default output iterator value type
|
||||
template <typename OutputIterator,
|
||||
typename CGAL_BGL_NP_TEMPLATE_PARAMETERS>
|
||||
bool
|
||||
read_ply_points(
|
||||
std::istream& stream, ///< input stream.
|
||||
OutputIterator output,
|
||||
const CGAL_BGL_NP_CLASS& np)
|
||||
{
|
||||
return read_ply_points<typename value_type_traits<OutputIterator>::type>
|
||||
(stream, output, np);
|
||||
}
|
||||
|
||||
/// @cond SKIP_IN_MANUAL
|
||||
// This variant creates a default point property map = Identity_property_map.
|
||||
//-----------------------------------------------------------------------------------
|
||||
// variant with default NP and output iterator value type
|
||||
template <typename OutputIterator>
|
||||
bool
|
||||
read_ply_points(
|
||||
std::istream& stream, ///< input stream.
|
||||
OutputIterator output)
|
||||
{
|
||||
return read_ply_points<typename value_type_traits<OutputIterator>::type>
|
||||
(stream, output, CGAL::parameters::all_default());
|
||||
}
|
||||
|
||||
// deprecated API
|
||||
template < typename OutputIteratorValueType,
|
||||
typename OutputIterator,
|
||||
typename NormalPMap >
|
||||
typename PointMap,
|
||||
typename NormalMap >
|
||||
bool read_ply_points_and_normals(std::istream& stream, ///< input stream.
|
||||
OutputIterator output, ///< output iterator over points.
|
||||
NormalPMap normal_pmap) ///< property map: value_type of OutputIterator -> Vector_3.
|
||||
PointMap point_map, ///< property map: value_type of OutputIterator -> Point_3.
|
||||
NormalMap normal_map) ///< property map: value_type of OutputIterator -> Vector_3.
|
||||
{
|
||||
return read_ply_points_and_normals
|
||||
<OutputIteratorValueType>(stream,
|
||||
output,
|
||||
make_identity_property_map(OutputIteratorValueType()),
|
||||
normal_pmap);
|
||||
CGAL_POINT_SET_PROCESSING_DEPRECATED_V1_API("read_ply_points_and_normals()");
|
||||
return read_ply_points<OutputIteratorValueType>
|
||||
(stream, output,
|
||||
CGAL::parameters::point_map (point_map).
|
||||
normal_map (normal_map));
|
||||
}
|
||||
|
||||
// deprecated API
|
||||
template < typename OutputIterator,
|
||||
typename PointMap,
|
||||
typename NormalMap >
|
||||
bool read_ply_points_and_normals(std::istream& stream, ///< input stream.
|
||||
OutputIterator output, ///< output iterator over points.
|
||||
PointMap point_map, ///< property map: value_type of OutputIterator -> Point_3.
|
||||
NormalMap normal_map) ///< property map: value_type of OutputIterator -> Vector_3.
|
||||
{
|
||||
CGAL_POINT_SET_PROCESSING_DEPRECATED_V1_API("read_ply_points_and_normals()");
|
||||
return read_ply_points<typename value_type_traits<OutputIterator>::type>
|
||||
(stream, output,
|
||||
CGAL::parameters::point_map (point_map).
|
||||
normal_map (normal_map));
|
||||
}
|
||||
|
||||
// deprecated API
|
||||
template < typename OutputIteratorValueType,
|
||||
typename OutputIterator,
|
||||
typename NormalMap >
|
||||
bool read_ply_points_and_normals(std::istream& stream, ///< input stream.
|
||||
OutputIterator output, ///< output iterator over points.
|
||||
NormalMap normal_map) ///< property map: value_type of OutputIterator -> Vector_3.
|
||||
{
|
||||
CGAL_POINT_SET_PROCESSING_DEPRECATED_V1_API("read_ply_points_and_normals()");
|
||||
return read_ply_points<OutputIteratorValueType>
|
||||
(stream, output,
|
||||
CGAL::parameters::normal_map (normal_map));
|
||||
}
|
||||
|
||||
template < typename OutputIterator,
|
||||
typename NormalPMap >
|
||||
typename NormalMap >
|
||||
bool read_ply_points_and_normals(std::istream& stream, ///< input stream.
|
||||
OutputIterator output, ///< output iterator over points.
|
||||
NormalPMap normal_pmap) ///< property map: value_type of OutputIterator -> Vector_3.
|
||||
NormalMap normal_map) ///< property map: value_type of OutputIterator -> Vector_3.
|
||||
{
|
||||
// just deduce value_type of OutputIterator
|
||||
return read_ply_points_and_normals
|
||||
<typename value_type_traits<OutputIterator>::type>(stream,
|
||||
output,
|
||||
normal_pmap);
|
||||
CGAL_POINT_SET_PROCESSING_DEPRECATED_V1_API("read_ply_points_and_normals()");
|
||||
return read_ply_points<typename value_type_traits<OutputIterator>::type>
|
||||
(stream, output,
|
||||
CGAL::parameters::normal_map (normal_map));
|
||||
}
|
||||
//-----------------------------------------------------------------------------------
|
||||
/// @endcond
|
||||
|
||||
// deprecated API
|
||||
template <typename OutputIteratorValueType,
|
||||
typename OutputIterator,
|
||||
typename PointMap
|
||||
>
|
||||
bool
|
||||
read_ply_points(
|
||||
std::istream& stream, ///< input stream.
|
||||
OutputIterator output, ///< output iterator over points.
|
||||
PointMap point_map) ///< property map: value_type of OutputIterator -> Point_3.
|
||||
{
|
||||
CGAL_POINT_SET_PROCESSING_DEPRECATED_V1_API("read_ply_points()");
|
||||
return read_ply_points<OutputIteratorValueType>
|
||||
(stream, output,
|
||||
CGAL::parameters::point_map (point_map));
|
||||
}
|
||||
|
||||
//===================================================================================
|
||||
/// \ingroup PkgPointSetProcessingIOPly
|
||||
/// Reads points (position only) from a .ply stream (ASCII or binary).
|
||||
/// Potential additional point properties (including normals) and faces are ignored.
|
||||
///
|
||||
/// @tparam OutputIteratorValueType type of objects that can be put in `OutputIterator`.
|
||||
/// It is default to `value_type_traits<OutputIterator>::%type` and can be omitted when the default is fine.
|
||||
/// @tparam OutputIterator iterator over output points.
|
||||
/// @tparam PointPMap is a model of `WritablePropertyMap` with value_type `CGAL::Point_3`.
|
||||
/// It can be omitted if the value type of `OutputIterator` is convertible to `CGAL::Point_3`.
|
||||
///
|
||||
/// @return `true` on success.
|
||||
///
|
||||
/// @cgalRequiresCPP11
|
||||
|
||||
// This variant requires all parameters.
|
||||
//-----------------------------------------------------------------------------------
|
||||
template < typename OutputIteratorValueType,
|
||||
typename OutputIterator,
|
||||
typename PointPMap >
|
||||
// deprecated API
|
||||
template < typename OutputIterator,
|
||||
typename PointMap >
|
||||
bool read_ply_points(std::istream& stream, ///< input stream.
|
||||
OutputIterator output, ///< output iterator over points.
|
||||
PointPMap point_pmap) ///< property map: value_type of OutputIterator -> Point_3.
|
||||
PointMap point_map) ///< property map: value_type of OutputIterator -> Point_3.
|
||||
{
|
||||
return read_ply_points_with_properties (stream, output,
|
||||
make_ply_point_reader (point_pmap));
|
||||
CGAL_POINT_SET_PROCESSING_DEPRECATED_V1_API("read_ply_points()");
|
||||
return read_ply_points<typename value_type_traits<OutputIterator>::type>
|
||||
(stream, output,
|
||||
CGAL::parameters::point_map (point_map));
|
||||
}
|
||||
|
||||
/// @cond SKIP_IN_MANUAL
|
||||
template < typename OutputIterator,
|
||||
typename PointPMap >
|
||||
bool read_ply_points(std::istream& stream, ///< input stream.
|
||||
OutputIterator output, ///< output iterator over points.
|
||||
PointPMap point_pmap) ///< property map: value_type of OutputIterator -> Point_3.
|
||||
{
|
||||
// just deduce value_type of OutputIterator
|
||||
return read_ply_points
|
||||
<typename value_type_traits<OutputIterator>::type>(stream,
|
||||
output,
|
||||
point_pmap);
|
||||
}
|
||||
//-----------------------------------------------------------------------------------
|
||||
/// @endcond
|
||||
|
||||
|
||||
/// @cond SKIP_IN_MANUAL
|
||||
// This variant creates a default point property map = Identity_property_map.
|
||||
//-----------------------------------------------------------------------------------
|
||||
template < typename OutputIteratorValueType,
|
||||
typename OutputIterator >
|
||||
bool read_ply_points(std::istream& stream, ///< input stream.
|
||||
OutputIterator output) ///< output iterator over points.
|
||||
{
|
||||
return read_ply_points
|
||||
<OutputIteratorValueType>(stream,
|
||||
output,
|
||||
make_identity_property_map(OutputIteratorValueType())
|
||||
);
|
||||
}
|
||||
|
||||
template < typename OutputIterator>
|
||||
bool read_ply_points(std::istream& stream, ///< input stream.
|
||||
OutputIterator output) ///< output iterator over points.
|
||||
{
|
||||
// just deduce value_type of OutputIterator
|
||||
return read_ply_points
|
||||
<typename value_type_traits<OutputIterator>::type>(stream,
|
||||
output);
|
||||
}
|
||||
//-----------------------------------------------------------------------------------
|
||||
|
||||
/// @endcond
|
||||
/// \endcond
|
||||
|
||||
|
||||
} //namespace CGAL
|
||||
|
|
|
|||
|
|
@ -30,48 +30,75 @@
|
|||
#include <CGAL/Origin.h>
|
||||
#include <CGAL/Kernel_traits.h>
|
||||
|
||||
#include <CGAL/boost/graph/named_function_params.h>
|
||||
#include <CGAL/boost/graph/named_params_helper.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
|
||||
namespace CGAL {
|
||||
|
||||
/**
|
||||
\ingroup PkgPointSetProcessingIO
|
||||
Reads points (positions + normals, if available) from a .xyz ASCII stream.
|
||||
The function expects for each point a line with the x y z position,
|
||||
optionally followed by the nx ny nz normal.
|
||||
The first line may contain the number of points in the file.
|
||||
Empty lines and comments starting by # character are allowed.
|
||||
|
||||
//===================================================================================
|
||||
/// \ingroup PkgPointSetProcessingIO
|
||||
/// Reads points (positions + normals, if available) from a .xyz ASCII stream.
|
||||
/// The function expects for each point a line with the x y z position,
|
||||
/// optionally followed by the nx ny nz normal.
|
||||
/// The first line may contain the number of points in the file.
|
||||
/// Empty lines and comments starting by # character are allowed.
|
||||
///
|
||||
/// @tparam OutputIteratorValueType type of objects that can be put in `OutputIterator`.
|
||||
/// It is default to `value_type_traits<OutputIterator>::%type` and can be omitted when the default is fine.
|
||||
/// @tparam OutputIterator iterator over output points.
|
||||
/// @tparam PointPMap is a model of `WritablePropertyMap` with value type `Point_3<Kernel>`.
|
||||
/// It can be omitted if the value type of OutputIterator value_type is convertible to `Point_3<Kernel>`.
|
||||
/// @tparam NormalPMap is a model of `WritablePropertyMap` with value type `Vector_3<Kernel>`.
|
||||
/// @tparam Kernel Geometric traits class.
|
||||
/// It can be omitted and deduced automatically from the value type of `PointPMap`.
|
||||
///
|
||||
/// @return true on success.
|
||||
\tparam OutputIteratorValueType type of objects that can be put in `OutputIterator`.
|
||||
It is default to `value_type_traits<OutputIterator>::%type` and can be omitted when the default is fine.
|
||||
\tparam OutputIterator iterator over output points.
|
||||
|
||||
// This variant requires all parameters.
|
||||
//-----------------------------------------------------------------------------------
|
||||
\param stream input stream.
|
||||
\param output output iterator over points.
|
||||
\param np optional sequence of \ref psp_namedparameters "Named Parameters" among the ones listed below.
|
||||
|
||||
\cgalNamedParamsBegin
|
||||
\cgalParamBegin{point_map} a model of `WritablePropertyMap` with value type `geom_traits::Point_3`.
|
||||
If this parameter is omitted, `CGAL::Identity_property_map<geom_traits::Point_3>` is used.\cgalParamEnd
|
||||
\cgalParamBegin{normal_map} a model of `ReadWritePropertyMap` with value type
|
||||
`geom_traits::Vector_3`. If this parameter is omitted, normals in the input stream are
|
||||
ignored.\cgalParamEnd
|
||||
\cgalParamBegin{geom_traits} an instance of a geometric traits class, model of `Kernel`\cgalParamEnd
|
||||
\cgalNamedParamsEnd
|
||||
|
||||
\return true on success.
|
||||
*/
|
||||
template <typename OutputIteratorValueType,
|
||||
typename OutputIterator,
|
||||
typename PointPMap,
|
||||
typename NormalPMap,
|
||||
typename Kernel
|
||||
#ifdef DOXYGEN_RUNNING
|
||||
typename NamedParameters
|
||||
#else
|
||||
typename CGAL_BGL_NP_TEMPLATE_PARAMETERS
|
||||
#endif
|
||||
>
|
||||
bool
|
||||
read_xyz_points_and_normals(
|
||||
std::istream& stream, ///< input stream.
|
||||
OutputIterator output, ///< output iterator over points.
|
||||
PointPMap point_pmap, ///< property map: value_type of OutputIterator -> Point_3.
|
||||
NormalPMap normal_pmap, ///< property map: value_type of OutputIterator -> Vector_3.
|
||||
const Kernel& /*kernel*/) ///< geometric traits.
|
||||
read_xyz_points(
|
||||
std::istream& stream,
|
||||
OutputIterator output,
|
||||
#ifdef DOXYGEN_RUNNING
|
||||
const NamedParameters& np)
|
||||
#else
|
||||
const CGAL_BGL_NP_CLASS& np)
|
||||
#endif
|
||||
{
|
||||
using boost::choose_param;
|
||||
|
||||
typedef Point_set_processing_3::Fake_point_range<OutputIteratorValueType> PointRange;
|
||||
|
||||
// basic geometric types
|
||||
typedef typename Point_set_processing_3::GetPointMap<PointRange, CGAL_BGL_NP_CLASS>::type PointMap;
|
||||
typedef typename Point_set_processing_3::GetNormalMap<PointRange, CGAL_BGL_NP_CLASS>::type NormalMap;
|
||||
typedef typename Point_set_processing_3::GetK<PointRange, CGAL_BGL_NP_CLASS>::Kernel Kernel;
|
||||
|
||||
bool has_normals = !(boost::is_same<NormalMap,
|
||||
typename Point_set_processing_3::GetNormalMap<PointRange, CGAL_BGL_NP_CLASS>::NoMap>::value);
|
||||
|
||||
PointMap point_map = choose_param(get_param(np, internal_np::point_map), PointMap());
|
||||
NormalMap normal_map = choose_param(get_param(np, internal_np::normal_map), NormalMap());
|
||||
|
||||
// value_type_traits is a workaround as back_insert_iterator's value_type is void
|
||||
//typedef typename value_type_traits<OutputIterator>::type Enriched_point;
|
||||
typedef OutputIteratorValueType Enriched_point;
|
||||
|
|
@ -129,8 +156,11 @@ read_xyz_points_and_normals(
|
|||
}
|
||||
}
|
||||
Enriched_point pwn;
|
||||
put(point_pmap, pwn, point); // point_pmap[pwn] = point
|
||||
put(normal_pmap, pwn, normal); // normal_pmap[pwn] = normal
|
||||
put(point_map, pwn, point); // point_map[pwn] = point
|
||||
|
||||
if (has_normals)
|
||||
put(normal_map, pwn, normal); // normal_map[pwn] = normal
|
||||
|
||||
*output++ = pwn;
|
||||
continue;
|
||||
}
|
||||
|
|
@ -151,7 +181,67 @@ read_xyz_points_and_normals(
|
|||
return true;
|
||||
}
|
||||
|
||||
/// @cond SKIP_IN_MANUAL
|
||||
/// \cond SKIP_IN_MANUAL
|
||||
// variant with default NP
|
||||
template <typename OutputIteratorValueType,
|
||||
typename OutputIterator>
|
||||
bool
|
||||
read_xyz_points(
|
||||
std::istream& stream, ///< input stream.
|
||||
OutputIterator output) ///< output iterator over points.
|
||||
{
|
||||
return read_xyz_points<OutputIteratorValueType>
|
||||
(stream, output, CGAL::parameters::all_default());
|
||||
}
|
||||
|
||||
// variant with default output iterator value type
|
||||
template <typename OutputIterator,
|
||||
typename CGAL_BGL_NP_TEMPLATE_PARAMETERS>
|
||||
bool
|
||||
read_xyz_points(
|
||||
std::istream& stream, ///< input stream.
|
||||
OutputIterator output,
|
||||
const CGAL_BGL_NP_CLASS& np)
|
||||
{
|
||||
return read_xyz_points<typename value_type_traits<OutputIterator>::type>
|
||||
(stream, output, np);
|
||||
}
|
||||
|
||||
// variant with default NP and output iterator value type
|
||||
template <typename OutputIterator>
|
||||
bool
|
||||
read_xyz_points(
|
||||
std::istream& stream, ///< input stream.
|
||||
OutputIterator output)
|
||||
{
|
||||
return read_xyz_points<typename value_type_traits<OutputIterator>::type>
|
||||
(stream, output, CGAL::parameters::all_default());
|
||||
}
|
||||
|
||||
// deprecated API
|
||||
template <typename OutputIteratorValueType,
|
||||
typename OutputIterator,
|
||||
typename PointPMap,
|
||||
typename NormalPMap,
|
||||
typename Kernel
|
||||
>
|
||||
bool
|
||||
read_xyz_points_and_normals(
|
||||
std::istream& stream, ///< input stream.
|
||||
OutputIterator output, ///< output iterator over points.
|
||||
PointPMap point_map, ///< property map: value_type of OutputIterator -> Point_3.
|
||||
NormalPMap normal_map, ///< property map: value_type of OutputIterator -> Vector_3.
|
||||
const Kernel& /*kernel*/) ///< geometric traits.
|
||||
{
|
||||
CGAL_POINT_SET_PROCESSING_DEPRECATED_V1_API("read_xyz_points_and_normals()");
|
||||
return read_xyz_points<OutputIteratorValueType>
|
||||
(stream, output,
|
||||
CGAL::parameters::point_map (point_map).
|
||||
normal_map (normal_map).
|
||||
geom_traits (Kernel()));
|
||||
}
|
||||
|
||||
// deprecated API
|
||||
template <typename OutputIterator,
|
||||
typename PointPMap,
|
||||
typename NormalPMap,
|
||||
|
|
@ -161,25 +251,19 @@ bool
|
|||
read_xyz_points_and_normals(
|
||||
std::istream& stream, ///< input stream.
|
||||
OutputIterator output, ///< output iterator over points.
|
||||
PointPMap point_pmap, ///< property map: value_type of OutputIterator -> Point_3.
|
||||
NormalPMap normal_pmap, ///< property map: value_type of OutputIterator -> Vector_3.
|
||||
PointPMap point_map, ///< property map: value_type of OutputIterator -> Point_3.
|
||||
NormalPMap normal_map, ///< property map: value_type of OutputIterator -> Vector_3.
|
||||
const Kernel& kernel) ///< geometric traits.
|
||||
{
|
||||
// just deduce value_type of OutputIterator
|
||||
return read_xyz_points_and_normals
|
||||
<typename value_type_traits<OutputIterator>::type>(
|
||||
stream,
|
||||
output,
|
||||
point_pmap,
|
||||
normal_pmap,
|
||||
kernel);
|
||||
CGAL_POINT_SET_PROCESSING_DEPRECATED_V1_API("read_xyz_points_and_normals()");
|
||||
return read_xyz_points<typename value_type_traits<OutputIterator>::type>
|
||||
(stream, output,
|
||||
CGAL::parameters::point_map (point_map).
|
||||
normal_map (normal_map).
|
||||
geom_traits (kernel));
|
||||
}
|
||||
//-----------------------------------------------------------------------------------
|
||||
/// @endcond
|
||||
|
||||
/// @cond SKIP_IN_MANUAL
|
||||
// This variant deduces the kernel from the point property map.
|
||||
//-----------------------------------------------------------------------------------
|
||||
// deprecated API
|
||||
template <typename OutputIteratorValueType,
|
||||
typename OutputIterator,
|
||||
typename PointPMap,
|
||||
|
|
@ -189,20 +273,17 @@ bool
|
|||
read_xyz_points_and_normals(
|
||||
std::istream& stream, ///< input stream.
|
||||
OutputIterator output, ///< output iterator over points.
|
||||
PointPMap point_pmap, ///< property map: value_type of OutputIterator -> Point_3.
|
||||
NormalPMap normal_pmap) ///< property map: value_type of OutputIterator -> Vector_3.
|
||||
PointPMap point_map, ///< property map: value_type of OutputIterator -> Point_3.
|
||||
NormalPMap normal_map) ///< property map: value_type of OutputIterator -> Vector_3.
|
||||
{
|
||||
typedef typename boost::property_traits<PointPMap>::value_type Point;
|
||||
typedef typename Kernel_traits<Point>::Kernel Kernel;
|
||||
return read_xyz_points_and_normals
|
||||
<OutputIteratorValueType>(
|
||||
stream,
|
||||
output,
|
||||
point_pmap,
|
||||
normal_pmap,
|
||||
Kernel());
|
||||
CGAL_POINT_SET_PROCESSING_DEPRECATED_V1_API("read_xyz_points_and_normals()");
|
||||
return read_xyz_points<OutputIteratorValueType>
|
||||
(stream, output,
|
||||
CGAL::parameters::point_map (point_map).
|
||||
normal_map (normal_map));
|
||||
}
|
||||
|
||||
// deprecated API
|
||||
template <typename OutputIterator,
|
||||
typename PointPMap,
|
||||
typename NormalPMap
|
||||
|
|
@ -211,23 +292,17 @@ bool
|
|||
read_xyz_points_and_normals(
|
||||
std::istream& stream, ///< input stream.
|
||||
OutputIterator output, ///< output iterator over points.
|
||||
PointPMap point_pmap, ///< property map: value_type of OutputIterator -> Point_3.
|
||||
NormalPMap normal_pmap) ///< property map: value_type of OutputIterator -> Vector_3.
|
||||
PointPMap point_map, ///< property map: value_type of OutputIterator -> Point_3.
|
||||
NormalPMap normal_map) ///< property map: value_type of OutputIterator -> Vector_3.
|
||||
{
|
||||
// just deduce value_type of OutputIterator
|
||||
return read_xyz_points_and_normals
|
||||
<typename value_type_traits<OutputIterator>::type>(
|
||||
stream,
|
||||
output,
|
||||
point_pmap,
|
||||
normal_pmap);
|
||||
CGAL_POINT_SET_PROCESSING_DEPRECATED_V1_API("read_xyz_points_and_normals()");
|
||||
return read_xyz_points<typename value_type_traits<OutputIterator>::type>
|
||||
(stream, output,
|
||||
CGAL::parameters::point_map (point_map).
|
||||
normal_map (normal_map));
|
||||
}
|
||||
//-----------------------------------------------------------------------------------
|
||||
/// @endcond
|
||||
|
||||
/// @cond SKIP_IN_MANUAL
|
||||
// This variant creates a default point property map = Identity_property_map.
|
||||
//-----------------------------------------------------------------------------------
|
||||
// deprecated API
|
||||
template <typename OutputIteratorValueType,
|
||||
typename OutputIterator,
|
||||
typename NormalPMap
|
||||
|
|
@ -236,16 +311,15 @@ bool
|
|||
read_xyz_points_and_normals(
|
||||
std::istream& stream, ///< input stream.
|
||||
OutputIterator output, ///< output iterator over points.
|
||||
NormalPMap normal_pmap) ///< property map: value_type of OutputIterator -> Vector_3.
|
||||
NormalPMap normal_map) ///< property map: value_type of OutputIterator -> Vector_3.
|
||||
{
|
||||
return read_xyz_points_and_normals
|
||||
<OutputIteratorValueType>(
|
||||
stream,
|
||||
output,
|
||||
make_identity_property_map(OutputIteratorValueType()),
|
||||
normal_pmap);
|
||||
CGAL_POINT_SET_PROCESSING_DEPRECATED_V1_API("read_xyz_points_and_normals()");
|
||||
return read_xyz_points<OutputIteratorValueType>
|
||||
(stream, output,
|
||||
CGAL::parameters::normal_map (normal_map));
|
||||
}
|
||||
|
||||
// deprecated API
|
||||
template <typename OutputIterator,
|
||||
typename NormalPMap
|
||||
>
|
||||
|
|
@ -253,39 +327,15 @@ bool
|
|||
read_xyz_points_and_normals(
|
||||
std::istream& stream, ///< input stream.
|
||||
OutputIterator output, ///< output iterator over points.
|
||||
NormalPMap normal_pmap) ///< property map: value_type of OutputIterator -> Vector_3.
|
||||
NormalPMap normal_map) ///< property map: value_type of OutputIterator -> Vector_3.
|
||||
{
|
||||
// just deduce value_type of OutputIterator
|
||||
return read_xyz_points_and_normals
|
||||
<typename value_type_traits<OutputIterator>::type>(
|
||||
stream,
|
||||
output,
|
||||
normal_pmap);
|
||||
CGAL_POINT_SET_PROCESSING_DEPRECATED_V1_API("read_xyz_points_and_normals()");
|
||||
return read_xyz_points<typename value_type_traits<OutputIterator>::type>
|
||||
(stream, output,
|
||||
CGAL::parameters::normal_map (normal_map));
|
||||
}
|
||||
//-----------------------------------------------------------------------------------
|
||||
/// @endcond
|
||||
|
||||
|
||||
//===================================================================================
|
||||
/// \ingroup PkgPointSetProcessingIO
|
||||
/// Reads points (positions only) from a .xyz ASCII stream.
|
||||
/// The function expects for each point a line with the x y z position.
|
||||
/// If the position is followed by the nx ny nz normal, then the normal will be ignored.
|
||||
/// The first line may contain the number of points in the file.
|
||||
/// Empty lines and comments starting by # character are allowed.
|
||||
///
|
||||
/// @tparam OutputIteratorValueType type of objects that can be put in `OutputIterator`.
|
||||
/// It is default to `value_type_traits<OutputIterator>::%type` and can be omitted when the default is fine.
|
||||
/// @tparam OutputIterator iterator over output points.
|
||||
/// @tparam PointPMap is a model of `WritablePropertyMap` with value type `Point_3<Kernel>`.
|
||||
/// It can be omitted if the value type of `OutputIterator` is convertible to `Point_3<Kernel>`.
|
||||
/// @tparam Kernel Geometric traits class.
|
||||
/// It can be omitted and deduced automatically from the value type of `PointPMap`.
|
||||
///
|
||||
/// @return true on success.
|
||||
|
||||
// This variant requires all parameters.
|
||||
//-----------------------------------------------------------------------------------
|
||||
// deprecated API
|
||||
template <typename OutputIteratorValueType,
|
||||
typename OutputIterator,
|
||||
typename PointPMap,
|
||||
|
|
@ -295,20 +345,17 @@ bool
|
|||
read_xyz_points(
|
||||
std::istream& stream, ///< input stream.
|
||||
OutputIterator output, ///< output iterator over points.
|
||||
PointPMap point_pmap, ///< property map: value_type of OutputIterator -> Point_3.
|
||||
PointPMap point_map, ///< property map: value_type of OutputIterator -> Point_3.
|
||||
const Kernel& kernel) ///< geometric traits.
|
||||
{
|
||||
// Calls read_xyz_points_and_normals() with a normal property map = boost::dummy_property_map
|
||||
return read_xyz_points_and_normals
|
||||
<OutputIteratorValueType>(
|
||||
stream,
|
||||
output,
|
||||
point_pmap,
|
||||
boost::dummy_property_map(),
|
||||
kernel);
|
||||
CGAL_POINT_SET_PROCESSING_DEPRECATED_V1_API("read_xyz_points()");
|
||||
return read_xyz_points<OutputIteratorValueType>
|
||||
(stream, output,
|
||||
CGAL::parameters::point_map (point_map).
|
||||
geom_traits (kernel));
|
||||
}
|
||||
|
||||
/// @cond SKIP_IN_MANUAL
|
||||
// deprecated API
|
||||
template <typename OutputIterator,
|
||||
typename PointPMap,
|
||||
typename Kernel
|
||||
|
|
@ -317,23 +364,17 @@ bool
|
|||
read_xyz_points(
|
||||
std::istream& stream, ///< input stream.
|
||||
OutputIterator output, ///< output iterator over points.
|
||||
PointPMap point_pmap, ///< property map: value_type of OutputIterator -> Point_3.
|
||||
PointPMap point_map, ///< property map: value_type of OutputIterator -> Point_3.
|
||||
const Kernel& kernel) ///< geometric traits.
|
||||
{
|
||||
// just deduce value_type of OutputIterator
|
||||
return read_xyz_points
|
||||
<typename value_type_traits<OutputIterator>::type>(
|
||||
stream,
|
||||
output,
|
||||
point_pmap,
|
||||
kernel);
|
||||
CGAL_POINT_SET_PROCESSING_DEPRECATED_V1_API("read_xyz_points()");
|
||||
return read_xyz_points<typename value_type_traits<OutputIterator>::type>
|
||||
(stream, output,
|
||||
CGAL::parameters::point_map (point_map).
|
||||
geom_traits (kernel));
|
||||
}
|
||||
/// @endcond
|
||||
//-----------------------------------------------------------------------------------
|
||||
|
||||
/// @cond SKIP_IN_MANUAL
|
||||
// This variant deduces the kernel from the point property map.
|
||||
//-----------------------------------------------------------------------------------
|
||||
// deprecated API
|
||||
template <typename OutputIteratorValueType,
|
||||
typename OutputIterator,
|
||||
typename PointPMap
|
||||
|
|
@ -342,18 +383,15 @@ bool
|
|||
read_xyz_points(
|
||||
std::istream& stream, ///< input stream.
|
||||
OutputIterator output, ///< output iterator over points.
|
||||
PointPMap point_pmap) ///< property map: value_type of OutputIterator -> Point_3.
|
||||
PointPMap point_map) ///< property map: value_type of OutputIterator -> Point_3.
|
||||
{
|
||||
typedef typename boost::property_traits<PointPMap>::value_type Point;
|
||||
typedef typename Kernel_traits<Point>::Kernel Kernel;
|
||||
return read_xyz_points
|
||||
<OutputIteratorValueType>(
|
||||
stream,
|
||||
output,
|
||||
point_pmap,
|
||||
Kernel());
|
||||
CGAL_POINT_SET_PROCESSING_DEPRECATED_V1_API("read_xyz_points()");
|
||||
return read_xyz_points<OutputIteratorValueType>
|
||||
(stream, output,
|
||||
CGAL::parameters::point_map (point_map));
|
||||
}
|
||||
|
||||
// deprecated API
|
||||
template <typename OutputIterator,
|
||||
typename PointPMap
|
||||
>
|
||||
|
|
@ -361,52 +399,15 @@ bool
|
|||
read_xyz_points(
|
||||
std::istream& stream, ///< input stream.
|
||||
OutputIterator output, ///< output iterator over points.
|
||||
PointPMap point_pmap) ///< property map: value_type of OutputIterator -> Point_3.
|
||||
PointPMap point_map) ///< property map: value_type of OutputIterator -> Point_3.
|
||||
{
|
||||
// just deduce value_type of OutputIterator
|
||||
return read_xyz_points
|
||||
<typename value_type_traits<OutputIterator>::type>(
|
||||
stream,
|
||||
output,
|
||||
point_pmap);
|
||||
}
|
||||
//-----------------------------------------------------------------------------------
|
||||
/// @endcond
|
||||
|
||||
/// @cond SKIP_IN_MANUAL
|
||||
// This variant creates a default point property map = Identity_property_map.
|
||||
//-----------------------------------------------------------------------------------
|
||||
template <typename OutputIteratorValueType,
|
||||
typename OutputIterator
|
||||
>
|
||||
bool
|
||||
read_xyz_points(
|
||||
std::istream& stream, ///< input stream.
|
||||
OutputIterator output) ///< output iterator over points.
|
||||
{
|
||||
return read_xyz_points
|
||||
<OutputIteratorValueType>(
|
||||
stream,
|
||||
output,
|
||||
make_identity_property_map(OutputIteratorValueType())
|
||||
);
|
||||
CGAL_POINT_SET_PROCESSING_DEPRECATED_V1_API("read_xyz_points()");
|
||||
return read_xyz_points<typename value_type_traits<OutputIterator>::type>
|
||||
(stream, output,
|
||||
CGAL::parameters::point_map (point_map));
|
||||
}
|
||||
|
||||
template <typename OutputIterator
|
||||
>
|
||||
bool
|
||||
read_xyz_points(
|
||||
std::istream& stream, ///< input stream.
|
||||
OutputIterator output) ///< output iterator over points.
|
||||
{
|
||||
// just deduce value_type of OutputIterator
|
||||
return read_xyz_points
|
||||
<typename value_type_traits<OutputIterator>::type>(
|
||||
stream,
|
||||
output);
|
||||
}
|
||||
//-----------------------------------------------------------------------------------
|
||||
/// @endcond
|
||||
/// \endcond
|
||||
|
||||
|
||||
} //namespace CGAL
|
||||
|
|
|
|||
|
|
@ -169,43 +169,44 @@ namespace internal {
|
|||
/// \endcond
|
||||
|
||||
|
||||
//===================================================================================
|
||||
/// \ingroup PkgPointSetProcessingIOLas
|
||||
/// Saves the [first, beyond) 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` vairable as an `int` %LAS property). An exception
|
||||
/// is used for points that are written using a `std::tuple` object.
|
||||
///
|
||||
/// See documentation of `read_las_points_with_properties()` for the
|
||||
/// list of available `LAS_property::Tag` classes.
|
||||
///
|
||||
/// @sa `make_las_point_writer()`
|
||||
///
|
||||
/// @cgalRequiresCPP11
|
||||
///
|
||||
/// @tparam ForwardIterator iterator over input points.
|
||||
/// @tparam PointMap is a model of `ReadablePropertyMap` with a value_type = `CGAL::Point_3`.
|
||||
/// @tparam PropertyHandler handlers to recover properties.
|
||||
///
|
||||
/// @return `true` on success.
|
||||
template <typename ForwardIterator,
|
||||
/**
|
||||
\ingroup PkgPointSetProcessingIOLas
|
||||
Saves 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` vairable as an `int` %LAS property). An exception
|
||||
is used for points that are written using a `std::tuple` object.
|
||||
|
||||
See documentation of `read_las_points_with_properties()` for the
|
||||
list of available `LAS_property::Tag` classes.
|
||||
|
||||
\sa `make_las_point_writer()`
|
||||
|
||||
\cgalRequiresCPP11
|
||||
|
||||
\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.
|
||||
|
||||
\return `true` on success.
|
||||
*/
|
||||
template <typename PointRange,
|
||||
typename PointMap,
|
||||
typename ... PropertyHandler>
|
||||
bool write_las_points_with_properties (std::ostream& stream, ///< output stream.
|
||||
ForwardIterator first, ///< iterator over the first input point.
|
||||
ForwardIterator beyond, ///< past-the-end iterator over the input points.
|
||||
const PoinRange& 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
|
||||
{
|
||||
CGAL_point_set_processing_precondition(first != beyond);
|
||||
CGAL_point_set_processing_precondition(points.begin() != points.end());
|
||||
|
||||
if(!stream)
|
||||
{
|
||||
|
|
@ -214,8 +215,10 @@ bool write_las_points_with_properties (std::ostream& stream, ///< output stream
|
|||
}
|
||||
|
||||
CGAL::Bbox_3 bbox = CGAL::bbox_3
|
||||
(boost::make_transform_iterator (first, CGAL::Property_map_to_unary_function<PointMap>(std::get<0>(point_property))),
|
||||
boost::make_transform_iterator (beyond, CGAL::Property_map_to_unary_function<PointMap>(std::get<0>(point_property))));
|
||||
(boost::make_transform_iterator
|
||||
(points.begin(), CGAL::Property_map_to_unary_function<PointMap>(std::get<0>(point_property))),
|
||||
boost::make_transform_iterator
|
||||
(points.end(), CGAL::Property_map_to_unary_function<PointMap>(std::get<0>(point_property))));
|
||||
|
||||
LASheader header;
|
||||
header.x_scale_factor = 1e-9 * (bbox.xmax() - bbox.xmin());
|
||||
|
|
@ -234,7 +237,7 @@ bool write_las_points_with_properties (std::ostream& stream, ///< output stream
|
|||
laswriter.open (stream, &header);
|
||||
|
||||
// Write positions + normals
|
||||
for(ForwardIterator it = first; it != beyond; it++)
|
||||
for(typename PointRange::const_iterator it = points.begin(); it != points.end(); it++)
|
||||
{
|
||||
const typename PointMap::value_type& p = get(std::get<0>(point_property), *it);
|
||||
laspoint.set_X ((unsigned int)((p.x() - header.x_offset) / header.x_scale_factor));
|
||||
|
|
@ -253,20 +256,56 @@ bool write_las_points_with_properties (std::ostream& stream, ///< output stream
|
|||
return ! stream.fail();
|
||||
}
|
||||
|
||||
//===================================================================================
|
||||
/// \ingroup PkgPointSetProcessingIOLas
|
||||
/// Saves the [first, beyond) range of points (positions only) to a
|
||||
/// .las stream.
|
||||
///
|
||||
/// @tparam ForwardIterator iterator over input points.
|
||||
/// @tparam PointMap is a model of `ReadablePropertyMap` with a value_type = `Point_3<Kernel>`.
|
||||
/// It can be omitted if the value type of `ForwardIterator` is convertible to `Point_3<Kernel>`.
|
||||
///
|
||||
/// @return `true` on success.
|
||||
///
|
||||
/// @cgalRequiresCPP11
|
||||
/**
|
||||
\ingroup PkgPointSetProcessingIOLas
|
||||
Saves the range of `points` (positions only) to a
|
||||
.las stream.
|
||||
|
||||
// This variant requires all parameters.
|
||||
\tparam PointRange is a model of `ConstRange`. The value type of
|
||||
its iterator is the key type of the named parameter `point_map`.
|
||||
|
||||
\param stream output stream.
|
||||
\param points input point range.
|
||||
\param np optional sequence of \ref psp_namedparameters "Named Parameters" among the ones listed below.
|
||||
|
||||
\cgalNamedParamsBegin
|
||||
\cgalParamBegin{point_map} a model of `ReadablePropertyMap` with value type `geom_traits::Point_3`.
|
||||
If this parameter is omitted, `CGAL::Identity_property_map<geom_traits::Point_3>` is used.\cgalParamEnd
|
||||
\cgalParamBegin{geom_traits} an instance of a geometric traits class, model of `Kernel`\cgalParamEnd
|
||||
\cgalNamedParamsEnd
|
||||
|
||||
\return true on success.
|
||||
\cgalRequiresCPP11
|
||||
*/
|
||||
template < typename PointRange,
|
||||
typename NamedParameters>
|
||||
bool
|
||||
write_las_points(
|
||||
std::ostream& stream,
|
||||
const PointRange& points,
|
||||
const NamedParameters& np)
|
||||
{
|
||||
using boost::choose_param;
|
||||
|
||||
typedef typename Point_set_processing_3::GetPointMap<PointRange, NamedParameters>::type PointMap;
|
||||
PointMap point_map = choose_param(get_param(np, internal_np::point_map), PointMap());
|
||||
|
||||
return write_las_points_with_properties (stream, points, make_las_point_writer(point_map));
|
||||
}
|
||||
|
||||
/// \cond SKIP_IN_MANUAL
|
||||
// variant with default NP
|
||||
template < typename PointRange>
|
||||
bool
|
||||
write_las_points(
|
||||
std::ostream& stream,
|
||||
const PointRange& points)
|
||||
{
|
||||
return write_las_points
|
||||
(stream, points, CGAL::Point_set_processing_3::parameters::all_default(points));
|
||||
}
|
||||
|
||||
// deprecated API
|
||||
template < typename ForwardIterator,
|
||||
typename PointMap >
|
||||
bool
|
||||
|
|
@ -276,11 +315,14 @@ write_las_points(
|
|||
ForwardIterator beyond, ///< past-the-end input point.
|
||||
PointMap point_map) ///< property map: value_type of OutputIterator -> Point_3.
|
||||
{
|
||||
return write_las_points_with_properties (stream, first, beyond, make_las_point_writer(point_map));
|
||||
CGAL_POINT_SET_PROCESSING_DEPRECATED_V1_API("write_las_points()");
|
||||
CGAL::Iterator_range<ForwardIterator> points (first, beyond);
|
||||
return write_las_points
|
||||
(stream, points,
|
||||
CGAL::parameters::point_map(point_map));
|
||||
}
|
||||
|
||||
/// @cond SKIP_IN_MANUAL
|
||||
// This variant creates a default point property map = Identity_property_map.
|
||||
|
||||
// deprecated API
|
||||
template < typename ForwardIterator >
|
||||
bool
|
||||
write_las_points(
|
||||
|
|
@ -288,14 +330,12 @@ write_las_points(
|
|||
ForwardIterator first, ///< first input point.
|
||||
ForwardIterator beyond) ///< past-the-end input point.
|
||||
{
|
||||
return write_las_points(
|
||||
stream,
|
||||
first, beyond,
|
||||
make_identity_property_map(
|
||||
typename std::iterator_traits<ForwardIterator>::value_type())
|
||||
);
|
||||
CGAL_POINT_SET_PROCESSING_DEPRECATED_V1_API("write_las_points()");
|
||||
CGAL::Iterator_range<ForwardIterator> points (first, beyond);
|
||||
return write_las_points
|
||||
(stream, points);
|
||||
}
|
||||
/// @endcond
|
||||
/// \endcond
|
||||
|
||||
|
||||
} //namespace CGAL
|
||||
|
|
|
|||
|
|
@ -33,39 +33,52 @@
|
|||
namespace CGAL {
|
||||
|
||||
|
||||
//===================================================================================
|
||||
/// \ingroup PkgPointSetProcessingIO
|
||||
/// Saves the [first, beyond) range of points (positions + normals) to a .off ASCII stream.
|
||||
/// The function writes for each point a line with the x y z position
|
||||
/// followed by the nx ny nz normal.
|
||||
///
|
||||
/// \pre normals must be unit vectors
|
||||
///
|
||||
/// @tparam ForwardIterator iterator over input points.
|
||||
/// @tparam PointPMap is a model of `ReadablePropertyMap` with value type `Point_3<Kernel>`.
|
||||
/// It can be omitted if the value type of `ForwardIterator` is convertible to `Point_3<Kernel>`.
|
||||
/// @tparam NormalPMap is a model of `ReadablePropertyMap` with a value type `Vector_3<Kernel>`.
|
||||
/// @tparam Kernel Geometric traits class.
|
||||
/// It can be omitted and deduced automatically from the value type of `PointPMap`.
|
||||
///
|
||||
/// @return true on success.
|
||||
/**
|
||||
\ingroup PkgPointSetProcessingIO
|
||||
Saves the range of `points` (positions + normals, if available) to a .off ASCII stream.
|
||||
The function writes for each point a line with the x y z position
|
||||
followed by the nx ny nz normal (if available).
|
||||
|
||||
// This variant requires all parameters.
|
||||
template <typename ForwardIterator,
|
||||
typename PointPMap,
|
||||
typename NormalPMap,
|
||||
typename Kernel
|
||||
\tparam PointRange is a model of `ConstRange`. The value type of
|
||||
its iterator is the key type of the named parameter `point_map`.
|
||||
|
||||
\param stream output stream.
|
||||
\param points input point range.
|
||||
\param np optional sequence of \ref psp_namedparameters "Named Parameters" among the ones listed below.
|
||||
|
||||
\cgalNamedParamsBegin
|
||||
\cgalParamBegin{point_map} a model of `ReadablePropertyMap` with value type `geom_traits::Point_3`.
|
||||
If this parameter is omitted, `CGAL::Identity_property_map<geom_traits::Point_3>` is used.\cgalParamEnd
|
||||
\cgalParamBegin{normal_map} a model of `ReadablePropertyMap` with value type
|
||||
`geom_traits::Vector_3`.\cgalParamEnd If this parameter is omitted, normals are not written to the
|
||||
output stream.\cgalParamEnd
|
||||
\cgalParamBegin{geom_traits} an instance of a geometric traits class, model of `Kernel`\cgalParamEnd
|
||||
\cgalNamedParamsEnd
|
||||
|
||||
\return true on success.
|
||||
*/
|
||||
template <typename PointRange,
|
||||
typename NamedParameters
|
||||
>
|
||||
bool
|
||||
write_off_points_and_normals(
|
||||
std::ostream& stream, ///< output stream.
|
||||
ForwardIterator first, ///< iterator over the first input point.
|
||||
ForwardIterator beyond, ///< past-the-end iterator over the input points.
|
||||
PointPMap point_pmap, ///< property map: value_type of ForwardIterator -> Point_3.
|
||||
NormalPMap normal_pmap, ///< property map: value_type of ForwardIterator -> Vector_3.
|
||||
const Kernel& /*kernel*/) ///< geometric traits.
|
||||
write_off_points(
|
||||
std::ostream& stream,
|
||||
const PointRange& points,
|
||||
const NamedParameters& np)
|
||||
{
|
||||
CGAL_point_set_processing_precondition(first != beyond);
|
||||
using boost::choose_param;
|
||||
|
||||
// basic geometric types
|
||||
typedef typename Point_set_processing_3::GetPointMap<PointRange, NamedParameters>::type PointMap;
|
||||
typedef typename Point_set_processing_3::GetNormalMap<PointRange, NamedParameters>::type NormalMap;
|
||||
|
||||
bool has_normals = !(boost::is_same<NormalMap,
|
||||
typename Point_set_processing_3::GetNormalMap<PointRange, NamedParameters>::NoMap>::value);
|
||||
|
||||
PointMap point_map = choose_param(get_param(np, internal_np::point_map), PointMap());
|
||||
NormalMap normal_map = choose_param(get_param(np, internal_np::normal_map), NormalMap());
|
||||
|
||||
CGAL_point_set_processing_precondition(points.begin() != points.end());
|
||||
|
||||
if(!stream)
|
||||
{
|
||||
|
|
@ -74,83 +87,99 @@ write_off_points_and_normals(
|
|||
}
|
||||
|
||||
// Write header
|
||||
const std::size_t num_input_points = std::distance(first, beyond);
|
||||
stream << "NOFF" << std::endl;
|
||||
stream << num_input_points << " 0 0" << std::endl;
|
||||
stream << points.size() << " 0 0" << std::endl;
|
||||
|
||||
// Write positions + normals
|
||||
for(ForwardIterator it = first; it != beyond; it++)
|
||||
for(typename PointRange::const_iterator it = points.begin(); it != points.end(); it++)
|
||||
{
|
||||
stream << get(point_pmap, *it) << " "
|
||||
<< get(normal_pmap, *it) << std::endl;
|
||||
stream << get(point_map, *it);
|
||||
if (has_normals)
|
||||
stream << " " << get(normal_map, *it);
|
||||
stream << std::endl;
|
||||
}
|
||||
|
||||
return ! stream.fail();
|
||||
}
|
||||
|
||||
/// @cond SKIP_IN_MANUAL
|
||||
// This variant deduces the kernel from the point property map.
|
||||
/// \cond SKIP_IN_MANUAL
|
||||
// variant with default NP
|
||||
template <typename PointRange>
|
||||
bool
|
||||
write_off_points(
|
||||
std::ostream& stream, ///< output stream.
|
||||
const PointRange& points)
|
||||
{
|
||||
return write_off_points
|
||||
(stream, points, CGAL::Point_set_processing_3::parameters::all_default(points));
|
||||
}
|
||||
|
||||
// deprecated API
|
||||
template <typename ForwardIterator,
|
||||
typename PointPMap,
|
||||
typename NormalPMap
|
||||
typename PointMap,
|
||||
typename NormalMap,
|
||||
typename Kernel
|
||||
>
|
||||
bool
|
||||
write_off_points_and_normals(
|
||||
std::ostream& stream, ///< output stream.
|
||||
ForwardIterator first, ///< iterator over the first input point.
|
||||
ForwardIterator beyond, ///< past-the-end iterator over the input points.
|
||||
PointMap point_map, ///< property map: value_type of ForwardIterator -> Point_3.
|
||||
NormalMap normal_map, ///< property map: value_type of ForwardIterator -> Vector_3.
|
||||
const Kernel& /*kernel*/) ///< geometric traits.
|
||||
{
|
||||
CGAL_POINT_SET_PROCESSING_DEPRECATED_V1_API("write_off_points_and_normals()");
|
||||
CGAL::Iterator_range<ForwardIterator> points (first, beyond);
|
||||
return write_off_points
|
||||
(stream, points,
|
||||
CGAL::parameters::point_map (point_map).
|
||||
normal_map (normal_map).
|
||||
geom_traits(Kernel()));
|
||||
}
|
||||
|
||||
// deprecated API
|
||||
template <typename ForwardIterator,
|
||||
typename PointMap,
|
||||
typename NormalMap
|
||||
>
|
||||
bool
|
||||
write_off_points_and_normals(
|
||||
std::ostream& stream, ///< output stream.
|
||||
ForwardIterator first, ///< first input point.
|
||||
ForwardIterator beyond, ///< past-the-end input point.
|
||||
PointPMap point_pmap, ///< property map: value_type of OutputIterator -> Point_3.
|
||||
NormalPMap normal_pmap) ///< property map: value_type of OutputIterator -> Vector_3.
|
||||
PointMap point_map, ///< property map: value_type of OutputIterator -> Point_3.
|
||||
NormalMap normal_map) ///< property map: value_type of OutputIterator -> Vector_3.
|
||||
{
|
||||
typedef typename boost::property_traits<PointPMap>::value_type Point;
|
||||
typedef typename Kernel_traits<Point>::Kernel Kernel;
|
||||
return write_off_points_and_normals(
|
||||
stream,
|
||||
first, beyond,
|
||||
point_pmap,
|
||||
normal_pmap,
|
||||
Kernel());
|
||||
CGAL_POINT_SET_PROCESSING_DEPRECATED_V1_API("write_off_points_and_normals()");
|
||||
CGAL::Iterator_range<ForwardIterator> points (first, beyond);
|
||||
return write_off_points
|
||||
(stream, points,
|
||||
CGAL::parameters::point_map (point_map).
|
||||
normal_map (normal_map));
|
||||
}
|
||||
/// @endcond
|
||||
|
||||
/// @cond SKIP_IN_MANUAL
|
||||
// This variant creates a default point property map = Identity_property_map.
|
||||
// deprecated API
|
||||
template <typename ForwardIterator,
|
||||
typename NormalPMap
|
||||
typename NormalMap
|
||||
>
|
||||
bool
|
||||
write_off_points_and_normals(
|
||||
std::ostream& stream, ///< output stream.
|
||||
ForwardIterator first, ///< first input point.
|
||||
ForwardIterator beyond, ///< past-the-end input point.
|
||||
NormalPMap normal_pmap) ///< property map: value_type of OutputIterator -> Vector_3.
|
||||
NormalMap normal_map) ///< property map: value_type of OutputIterator -> Vector_3.
|
||||
{
|
||||
return write_off_points_and_normals(
|
||||
stream,
|
||||
first, beyond,
|
||||
make_identity_property_map(
|
||||
typename std::iterator_traits<ForwardIterator>::value_type()),
|
||||
normal_pmap);
|
||||
CGAL_POINT_SET_PROCESSING_DEPRECATED_V1_API("write_off_points_and_normals()");
|
||||
CGAL::Iterator_range<ForwardIterator> points (first, beyond);
|
||||
return write_off_points
|
||||
(stream, points,
|
||||
CGAL::parameters::normal_map (normal_map));
|
||||
}
|
||||
/// @endcond
|
||||
|
||||
|
||||
//===================================================================================
|
||||
/// \ingroup PkgPointSetProcessingIO
|
||||
/// Saves the [first, beyond) range of points (positions only) to a .off ASCII stream.
|
||||
/// The function writes for each point a line with the x y z position.
|
||||
///
|
||||
/// @tparam ForwardIterator iterator over input points.
|
||||
/// @tparam PointPMap is a model of `ReadablePropertyMap` with a value_type = `Point_3<Kernel>`.
|
||||
/// It can be omitted if the value type of `ForwardIterator` is convertible to `Point_3<Kernel>`.
|
||||
/// @tparam Kernel Geometric traits class.
|
||||
/// It can be omitted and deduced automatically from the value type of `PointPMap`.
|
||||
///
|
||||
/// @return true on success.
|
||||
|
||||
// This variant requires all parameters.
|
||||
// deprecated API
|
||||
template <typename ForwardIterator,
|
||||
typename PointPMap,
|
||||
typename PointMap,
|
||||
typename Kernel
|
||||
>
|
||||
bool
|
||||
|
|
@ -158,53 +187,36 @@ write_off_points(
|
|||
std::ostream& stream, ///< output stream.
|
||||
ForwardIterator first, ///< iterator over the first input point.
|
||||
ForwardIterator beyond, ///< past-the-end iterator over the input points.
|
||||
PointPMap point_pmap, ///< property map: value_type of ForwardIterator -> Point_3.
|
||||
PointMap point_map, ///< property map: value_type of ForwardIterator -> Point_3.
|
||||
const Kernel& ) ///< geometric traits.
|
||||
{
|
||||
CGAL_point_set_processing_precondition(first != beyond);
|
||||
|
||||
if(!stream)
|
||||
{
|
||||
std::cerr << "Error: cannot open file" << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
// Write header
|
||||
const std::size_t num_input_points = std::distance(first, beyond);
|
||||
stream << "OFF" << std::endl;
|
||||
stream << num_input_points << " 0 0" << std::endl;
|
||||
|
||||
// Write positions
|
||||
for(ForwardIterator it = first; it != beyond; it++)
|
||||
stream << get(point_pmap, *it) << std::endl;
|
||||
|
||||
return ! stream.fail();
|
||||
CGAL_POINT_SET_PROCESSING_DEPRECATED_V1_API("write_off_points()");
|
||||
CGAL::Iterator_range<ForwardIterator> points (first, beyond);
|
||||
return write_off_points
|
||||
(stream, points,
|
||||
CGAL::parameters::point_map (point_map).
|
||||
geom_traits (Kernel());
|
||||
}
|
||||
|
||||
/// @cond SKIP_IN_MANUAL
|
||||
// This variant deduces the kernel from the point property map.
|
||||
// deprecated API
|
||||
template <typename ForwardIterator,
|
||||
typename PointPMap
|
||||
typename PointMap
|
||||
>
|
||||
bool
|
||||
write_off_points(
|
||||
std::ostream& stream, ///< output stream.
|
||||
ForwardIterator first, ///< first input point.
|
||||
ForwardIterator beyond, ///< past-the-end input point.
|
||||
PointPMap point_pmap) ///< property map: value_type of OutputIterator -> Point_3.
|
||||
PointMap point_map) ///< property map: value_type of OutputIterator -> Point_3.
|
||||
{
|
||||
typedef typename boost::property_traits<PointPMap>::value_type Point;
|
||||
typedef typename Kernel_traits<Point>::Kernel Kernel;
|
||||
return write_off_points(
|
||||
stream,
|
||||
first, beyond,
|
||||
point_pmap,
|
||||
Kernel());
|
||||
CGAL_POINT_SET_PROCESSING_DEPRECATED_V1_API("write_off_points()");
|
||||
CGAL::Iterator_range<ForwardIterator> points (first, beyond);
|
||||
return write_off_points
|
||||
(stream, points,
|
||||
CGAL::parameters::point_map (point_map));
|
||||
}
|
||||
/// @endcond
|
||||
|
||||
/// @cond SKIP_IN_MANUAL
|
||||
// This variant creates a default point property map = Identity_property_map.
|
||||
// deprecated API
|
||||
template <typename ForwardIterator
|
||||
>
|
||||
bool
|
||||
|
|
@ -213,14 +225,12 @@ write_off_points(
|
|||
ForwardIterator first, ///< first input point.
|
||||
ForwardIterator beyond) ///< past-the-end input point.
|
||||
{
|
||||
return write_off_points(
|
||||
stream,
|
||||
first, beyond,
|
||||
make_identity_property_map(
|
||||
typename std::iterator_traits<ForwardIterator>::value_type())
|
||||
);
|
||||
CGAL_POINT_SET_PROCESSING_DEPRECATED_V1_API("write_off_points()");
|
||||
CGAL::Iterator_range<ForwardIterator> points (first, beyond);
|
||||
return write_off_points
|
||||
(stream, points);
|
||||
}
|
||||
/// @endcond
|
||||
/// \endcond
|
||||
|
||||
|
||||
} //namespace CGAL
|
||||
|
|
|
|||
|
|
@ -33,6 +33,10 @@
|
|||
#include <CGAL/property_map.h>
|
||||
#include <CGAL/point_set_processing_assertions.h>
|
||||
#include <CGAL/IO/read_ply_points.h>
|
||||
#include <CGAL/Iterator_range.h>
|
||||
|
||||
#include <CGAL/boost/graph/named_function_params.h>
|
||||
#include <CGAL/boost/graph/named_params_helper.h>
|
||||
|
||||
#include <boost/version.hpp>
|
||||
|
||||
|
|
@ -293,44 +297,45 @@ namespace internal {
|
|||
/// \endcond
|
||||
|
||||
|
||||
//===================================================================================
|
||||
/// \ingroup PkgPointSetProcessingIOPly
|
||||
/// Saves the [first, beyond) range of points with properties to a
|
||||
/// .ply stream. %PLY is either ASCII or binary depending on the value
|
||||
/// of `CGAL::get_mode(stream)`.
|
||||
///
|
||||
/// 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::get_mode()`).
|
||||
///
|
||||
/// @sa `make_ply_point_writer()`
|
||||
/// @sa `make_ply_normal_writer()`
|
||||
///
|
||||
/// @cgalRequiresCPP11
|
||||
///
|
||||
/// @tparam ForwardIterator iterator over input points.
|
||||
/// @tparam PropertyHandler handlers to recover properties.
|
||||
///
|
||||
/// @return `true` on success.
|
||||
template < typename ForwardIterator,
|
||||
/**
|
||||
\ingroup PkgPointSetProcessingIOPly
|
||||
Saves the range of `points` with properties to a
|
||||
.ply stream. %PLY is either ASCII or binary depending on the value
|
||||
of `CGAL::get_mode(stream)`.
|
||||
|
||||
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::get_mode()`).
|
||||
|
||||
\sa `make_ply_point_writer()`
|
||||
\sa `make_ply_normal_writer()`
|
||||
|
||||
\cgalRequiresCPP11
|
||||
|
||||
\tparam PointRange is a model of `ConstRange`. The value type of
|
||||
its iterator is the key type of the named parameter `point_map`.
|
||||
\tparam PropertyHandler handlers to recover properties.
|
||||
|
||||
\return `true` on success.
|
||||
*/
|
||||
template < typename PointRange,
|
||||
typename ... PropertyHandler>
|
||||
bool
|
||||
write_ply_points_with_properties(
|
||||
std::ostream& stream, ///< output stream.
|
||||
ForwardIterator first, ///< iterator over the first input point.
|
||||
ForwardIterator beyond, ///< past-the-end iterator over the input points.
|
||||
const PointRange& points, ///< input point range.
|
||||
PropertyHandler&& ... properties) ///< parameter pack of property handlers
|
||||
{
|
||||
CGAL_point_set_processing_precondition(first != beyond);
|
||||
CGAL_point_set_processing_precondition(points.begin() != points.end());
|
||||
|
||||
if(!stream)
|
||||
{
|
||||
|
|
@ -342,7 +347,7 @@ write_ply_points_with_properties(
|
|||
stream << "ply" << std::endl
|
||||
<< ((get_mode(stream) == IO::BINARY) ? "format binary_little_endian 1.0" : "format ascii 1.0") << std::endl
|
||||
<< "comment Generated by the CGAL library" << std::endl
|
||||
<< "element vertex " << std::distance (first, beyond) << std::endl;
|
||||
<< "element vertex " << points.size() << std::endl;
|
||||
|
||||
internal::PLY::output_property_header (stream, std::forward<PropertyHandler>(properties)...);
|
||||
|
||||
|
|
@ -350,33 +355,83 @@ write_ply_points_with_properties(
|
|||
|
||||
|
||||
// Write positions + normals
|
||||
for(ForwardIterator it = first; it != beyond; it++)
|
||||
for(typename PointRange::const_iterator it = points.begin(); it != points.end(); it++)
|
||||
{
|
||||
internal::PLY::output_properties (stream, it, std::forward<PropertyHandler>(properties)...);
|
||||
}
|
||||
|
||||
return ! stream.fail();
|
||||
|
||||
}
|
||||
|
||||
//===================================================================================
|
||||
/// \ingroup PkgPointSetProcessingIOPly
|
||||
/// Saves the [first, beyond) range of points (positions + normals) to
|
||||
/// a .ply stream. %PLY is either ASCII or binary depending on the
|
||||
/// value of `CGAL::get_mode(stream)`.
|
||||
///
|
||||
/// \pre normals must be unit vectors
|
||||
///
|
||||
/// @tparam ForwardIterator iterator over input points.
|
||||
/// @tparam PointMap is a model of `ReadablePropertyMap` with value type `CGAL::Point_3`.
|
||||
/// It can be omitted if the value type of `ForwardIterator` is convertible to `CGAL::Point_3`.
|
||||
/// @tparam VectorMap is a model of `ReadablePropertyMap` with a value type `CGAL::Vector_3`.
|
||||
///
|
||||
/// @return `true` on success.
|
||||
///
|
||||
/// @cgalRequiresCPP11
|
||||
/**
|
||||
\ingroup PkgPointSetProcessingIOPly
|
||||
Saves the range of `points` (positions + normals, if available) to
|
||||
a .ply stream. %PLY is either ASCII or binary depending on the
|
||||
value of `CGAL::get_mode(stream)`.
|
||||
|
||||
// This variant requires all parameters.
|
||||
\tparam PointRange is a model of `ConstRange`. The value type of
|
||||
its iterator is the key type of the named parameter `point_map`.
|
||||
|
||||
\param stream output stream.
|
||||
\param points input point range.
|
||||
\param np optional sequence of \ref psp_namedparameters "Named Parameters" among the ones listed below.
|
||||
|
||||
\cgalNamedParamsBegin
|
||||
\cgalParamBegin{point_map} a model of `ReadablePropertyMap` with value type `geom_traits::Point_3`.
|
||||
If this parameter is omitted, `CGAL::Identity_property_map<geom_traits::Point_3>` is used.\cgalParamEnd
|
||||
\cgalParamBegin{normal_map} a model of `ReadablePropertyMap` with value type
|
||||
`geom_traits::Vector_3`.\cgalParamEnd If this parameter is omitted, normals are not written to the
|
||||
output stream.\cgalParamEnd
|
||||
\cgalParamBegin{geom_traits} an instance of a geometric traits class, model of `Kernel`\cgalParamEnd
|
||||
\cgalNamedParamsEnd
|
||||
|
||||
\return true on success.
|
||||
\cgalRequiresCPP11
|
||||
*/
|
||||
template <typename PointRange,
|
||||
typename NamedParameters>
|
||||
bool
|
||||
write_ply_points(
|
||||
std::ostream& stream,
|
||||
const PointRange& points,
|
||||
const NamedParameters& np)
|
||||
{
|
||||
using boost::choose_param;
|
||||
|
||||
// basic geometric types
|
||||
typedef typename Point_set_processing_3::GetPointMap<PointRange, NamedParameters>::type PointMap;
|
||||
typedef typename Point_set_processing_3::GetNormalMap<PointRange, NamedParameters>::type NormalMap;
|
||||
|
||||
bool has_normals = !(boost::is_same<NormalMap,
|
||||
typename Point_set_processing_3::GetNormalMap<PointRange, NamedParameters>::NoMap>::value);
|
||||
|
||||
PointMap point_map = choose_param(get_param(np, internal_np::point_map), PointMap());
|
||||
NormalMap normal_map = choose_param(get_param(np, internal_np::normal_map), NormalMap());
|
||||
|
||||
if (has_normals)
|
||||
return write_ply_points_with_properties(
|
||||
stream, points,
|
||||
make_ply_point_writer(point_map),
|
||||
make_ply_normal_writer(normal_map));
|
||||
// else
|
||||
return write_ply_points_with_properties(
|
||||
stream, points,
|
||||
make_ply_point_writer(point_map));
|
||||
}
|
||||
|
||||
/// \cond SKIP_IN_MANUAL
|
||||
// variant with default NP
|
||||
template <typename PointRange>
|
||||
bool
|
||||
write_ply_points(
|
||||
std::ostream& stream,
|
||||
const PointRange& points)
|
||||
{
|
||||
return write_ply_points
|
||||
(stream, points, CGAL::Point_set_processing_3::parameters::all_default(points));
|
||||
}
|
||||
|
||||
// deprecated API
|
||||
template < typename ForwardIterator,
|
||||
typename PointMap,
|
||||
typename VectorMap >
|
||||
|
|
@ -388,15 +443,15 @@ write_ply_points_and_normals(
|
|||
PointMap point_map, ///< property map: value_type of OutputIterator -> Point_3.
|
||||
VectorMap normal_map) ///< property map: value_type of OutputIterator -> Vector_3.
|
||||
{
|
||||
return write_ply_points_with_properties(
|
||||
stream,
|
||||
first, beyond,
|
||||
make_ply_point_writer(point_map),
|
||||
make_ply_normal_writer(normal_map));
|
||||
CGAL_POINT_SET_PROCESSING_DEPRECATED_V1_API("write_ply_points_and_normals()");
|
||||
CGAL::Iterator_range<ForwardIterator> points (first, beyond);
|
||||
return write_ply_points
|
||||
(stream, points,
|
||||
CGAL::parameters::point_map (point_map).
|
||||
normal_map (normal_map));
|
||||
}
|
||||
|
||||
/// @cond SKIP_IN_MANUAL
|
||||
// This variant creates a default point property map = Identity_property_map.
|
||||
|
||||
// deprecated API
|
||||
template <typename ForwardIterator,
|
||||
typename VectorMap
|
||||
>
|
||||
|
|
@ -407,31 +462,14 @@ write_ply_points_and_normals(
|
|||
ForwardIterator beyond, ///< past-the-end input point.
|
||||
VectorMap normal_map) ///< property map: value_type of OutputIterator -> Vector_3.
|
||||
{
|
||||
return write_ply_points_and_normals(
|
||||
stream,
|
||||
first, beyond,
|
||||
make_identity_property_map(
|
||||
typename std::iterator_traits<ForwardIterator>::value_type()),
|
||||
normal_map);
|
||||
CGAL_POINT_SET_PROCESSING_DEPRECATED_V1_API("write_ply_points_and_normals()");
|
||||
CGAL::Iterator_range<ForwardIterator> points (first, beyond);
|
||||
return write_ply_points
|
||||
(stream, points,
|
||||
CGAL::parameters::normal_map (normal_map));
|
||||
}
|
||||
/// @endcond
|
||||
|
||||
|
||||
//===================================================================================
|
||||
/// \ingroup PkgPointSetProcessingIOPly
|
||||
/// Saves the [first, beyond) range of points (positions only) to a
|
||||
/// .ply stream. %PLY is either ASCII or binary depending on the value
|
||||
/// of `CGAL::get_mode(stream)`.
|
||||
///
|
||||
/// @tparam ForwardIterator iterator over input points.
|
||||
/// @tparam PointMap is a model of `ReadablePropertyMap` with a value_type = `CGAL::Point_3`.
|
||||
/// It can be omitted if the value type of `ForwardIterator` is convertible to `CGAL::Point_3`.
|
||||
///
|
||||
/// @return `true` on success.
|
||||
///
|
||||
/// @cgalRequiresCPP11
|
||||
|
||||
// This variant requires all parameters.
|
||||
// deprecated API
|
||||
template < typename ForwardIterator,
|
||||
typename PointMap >
|
||||
bool
|
||||
|
|
@ -441,11 +479,14 @@ write_ply_points(
|
|||
ForwardIterator beyond, ///< past-the-end input point.
|
||||
PointMap point_map) ///< property map: value_type of OutputIterator -> Point_3.
|
||||
{
|
||||
return write_ply_points_with_properties (stream, first, beyond, make_ply_point_writer(point_map));
|
||||
CGAL_POINT_SET_PROCESSING_DEPRECATED_V1_API("write_ply_points()");
|
||||
CGAL::Iterator_range<ForwardIterator> points (first, beyond);
|
||||
return write_ply_points
|
||||
(stream, points,
|
||||
CGAL::parameters::point_map(point_map));
|
||||
}
|
||||
|
||||
/// @cond SKIP_IN_MANUAL
|
||||
// This variant creates a default point property map = Identity_property_map.
|
||||
// deprecated API
|
||||
template < typename ForwardIterator >
|
||||
bool
|
||||
write_ply_points(
|
||||
|
|
@ -453,14 +494,12 @@ write_ply_points(
|
|||
ForwardIterator first, ///< first input point.
|
||||
ForwardIterator beyond) ///< past-the-end input point.
|
||||
{
|
||||
return write_ply_points(
|
||||
stream,
|
||||
first, beyond,
|
||||
make_identity_property_map(
|
||||
typename std::iterator_traits<ForwardIterator>::value_type())
|
||||
);
|
||||
CGAL_POINT_SET_PROCESSING_DEPRECATED_V1_API("write_ply_points()");
|
||||
CGAL::Iterator_range<ForwardIterator> points (first, beyond);
|
||||
return write_ply_points
|
||||
(stream, points);
|
||||
}
|
||||
/// @endcond
|
||||
/// \endcond
|
||||
|
||||
|
||||
} //namespace CGAL
|
||||
|
|
|
|||
|
|
@ -27,6 +27,10 @@
|
|||
#include <CGAL/property_map.h>
|
||||
#include <CGAL/point_set_processing_assertions.h>
|
||||
#include <CGAL/Kernel_traits.h>
|
||||
#include <CGAL/Iterator_range.h>
|
||||
|
||||
#include <CGAL/boost/graph/named_function_params.h>
|
||||
#include <CGAL/boost/graph/named_params_helper.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <iterator>
|
||||
|
|
@ -34,39 +38,52 @@
|
|||
namespace CGAL {
|
||||
|
||||
|
||||
//===================================================================================
|
||||
/// \ingroup PkgPointSetProcessingIO
|
||||
/// Saves the [first, beyond) range of points (positions + normals) to a .xyz ASCII stream.
|
||||
/// The function writes for each point a line with the x y z position
|
||||
/// followed by the nx ny nz normal.
|
||||
///
|
||||
/// \pre normals must be unit vectors
|
||||
///
|
||||
/// @tparam ForwardIterator iterator over input points.
|
||||
/// @tparam PointPMap is a model of `ReadablePropertyMap` with a value type = `Point_3<Kernel>`.
|
||||
/// It can be omitted if the value type of `ForwardIterator` is convertible to `Point_3<Kernel>`.
|
||||
/// @tparam NormalPMap is a model of `ReadablePropertyMap` with a value type `Vector_3<Kernel>`.
|
||||
/// @tparam Kernel Geometric traits class.
|
||||
/// It can be omitted and deduced automatically from the value type of `PointPMap`.
|
||||
///
|
||||
/// @return true on success.
|
||||
/**
|
||||
\ingroup PkgPointSetProcessingIO
|
||||
Saves the range of `points` (positions + normals, if available) to a .xyz ASCII stream.
|
||||
The function writes for each point a line with the x y z position
|
||||
followed by the nx ny nz normal (if available).
|
||||
|
||||
// This variant requires all parameters.
|
||||
template <typename ForwardIterator,
|
||||
typename PointPMap,
|
||||
typename NormalPMap,
|
||||
typename Kernel
|
||||
\tparam PointRange is a model of `ConstRange`. The value type of
|
||||
its iterator is the key type of the named parameter `point_map`.
|
||||
|
||||
\param stream output stream.
|
||||
\param points input point range.
|
||||
\param np optional sequence of \ref psp_namedparameters "Named Parameters" among the ones listed below.
|
||||
|
||||
\cgalNamedParamsBegin
|
||||
\cgalParamBegin{point_map} a model of `ReadablePropertyMap` with value type `geom_traits::Point_3`.
|
||||
If this parameter is omitted, `CGAL::Identity_property_map<geom_traits::Point_3>` is used.\cgalParamEnd
|
||||
\cgalParamBegin{normal_map} a model of `ReadablePropertyMap` with value type
|
||||
`geom_traits::Vector_3`.\cgalParamEnd If this parameter is omitted, normals are not written to the
|
||||
output stream.\cgalParamEnd
|
||||
\cgalParamBegin{geom_traits} an instance of a geometric traits class, model of `Kernel`\cgalParamEnd
|
||||
\cgalNamedParamsEnd
|
||||
|
||||
\return true on success.
|
||||
*/
|
||||
template <typename PointRange,
|
||||
typename NamedParameters
|
||||
>
|
||||
bool
|
||||
write_xyz_points_and_normals(
|
||||
std::ostream& stream, ///< output stream.
|
||||
ForwardIterator first, ///< iterator over the first input point.
|
||||
ForwardIterator beyond, ///< past-the-end iterator over the input points.
|
||||
PointPMap point_pmap, ///< property map: value_type of ForwardIterator -> Point_3.
|
||||
NormalPMap normal_pmap, ///< property map: value_type of ForwardIterator -> Vector_3.
|
||||
const Kernel& /*kernel*/) ///< geometric traits.
|
||||
write_xyz_points(
|
||||
std::ostream& stream,
|
||||
const PointRange& points,
|
||||
const NamedParameters& np)
|
||||
{
|
||||
CGAL_point_set_processing_precondition(first != beyond);
|
||||
using boost::choose_param;
|
||||
|
||||
// basic geometric types
|
||||
typedef typename Point_set_processing_3::GetPointMap<PointRange, NamedParameters>::type PointMap;
|
||||
typedef typename Point_set_processing_3::GetNormalMap<PointRange, NamedParameters>::type NormalMap;
|
||||
|
||||
bool has_normals = !(boost::is_same<NormalMap,
|
||||
typename Point_set_processing_3::GetNormalMap<PointRange, NamedParameters>::NoMap>::value);
|
||||
|
||||
PointMap point_map = choose_param(get_param(np, internal_np::point_map), PointMap());
|
||||
NormalMap normal_map = choose_param(get_param(np, internal_np::normal_map), NormalMap());
|
||||
|
||||
CGAL_point_set_processing_precondition(points.begin() != points.end());
|
||||
|
||||
if(!stream)
|
||||
{
|
||||
|
|
@ -75,127 +92,131 @@ write_xyz_points_and_normals(
|
|||
}
|
||||
|
||||
// Write positions + normals
|
||||
for(ForwardIterator it = first; it != beyond; it++)
|
||||
for(typename PointRange::const_iterator it = points.begin(); it != points.end(); it++)
|
||||
{
|
||||
stream << get(point_pmap, *it) << " "
|
||||
<< get(normal_pmap, *it) << std::endl;
|
||||
stream << get(point_map, *it);
|
||||
if (has_normals)
|
||||
stream << " " << get(normal_map, *it);
|
||||
stream << std::endl;
|
||||
}
|
||||
|
||||
return ! stream.fail();
|
||||
}
|
||||
|
||||
/// @cond SKIP_IN_MANUAL
|
||||
// This variant deduces the kernel from the point property map.
|
||||
/// \cond SKIP_IN_MANUAL
|
||||
// variant with default NP
|
||||
template <typename PointRange>
|
||||
bool
|
||||
write_xyz_points(
|
||||
std::ostream& stream, ///< output stream.
|
||||
const PointRange& points)
|
||||
{
|
||||
return write_xyz_points
|
||||
(stream, points, CGAL::Point_set_processing_3::parameters::all_default(points));
|
||||
}
|
||||
|
||||
// deprecated API
|
||||
template <typename ForwardIterator,
|
||||
typename PointPMap,
|
||||
typename NormalPMap
|
||||
typename PointMap,
|
||||
typename NormalMap,
|
||||
typename Kernel
|
||||
>
|
||||
bool
|
||||
write_xyz_points_and_normals(
|
||||
std::ostream& stream, ///< output stream.
|
||||
ForwardIterator first, ///< iterator over the first input point.
|
||||
ForwardIterator beyond, ///< past-the-end iterator over the input points.
|
||||
PointMap point_map, ///< property map: value_type of ForwardIterator -> Point_3.
|
||||
NormalMap normal_map, ///< property map: value_type of ForwardIterator -> Vector_3.
|
||||
const Kernel& /*kernel*/) ///< geometric traits.
|
||||
{
|
||||
CGAL_POINT_SET_PROCESSING_DEPRECATED_V1_API("write_xyz_points_and_normals()");
|
||||
CGAL::Iterator_range<ForwardIterator> points (first, beyond);
|
||||
return write_xyz_points
|
||||
(stream, points,
|
||||
CGAL::parameters::point_map (point_map).
|
||||
normal_map (normal_map).
|
||||
geom_traits(Kernel()));
|
||||
}
|
||||
|
||||
// deprecated API
|
||||
template <typename ForwardIterator,
|
||||
typename PointMap,
|
||||
typename NormalMap
|
||||
>
|
||||
bool
|
||||
write_xyz_points_and_normals(
|
||||
std::ostream& stream, ///< output stream.
|
||||
ForwardIterator first, ///< first input point.
|
||||
ForwardIterator beyond, ///< past-the-end input point.
|
||||
PointPMap point_pmap, ///< property map: value_type of OutputIterator -> Point_3.
|
||||
NormalPMap normal_pmap) ///< property map: value_type of OutputIterator -> Vector_3.
|
||||
PointMap point_map, ///< property map: value_type of OutputIterator -> Point_3.
|
||||
NormalMap normal_map) ///< property map: value_type of OutputIterator -> Vector_3.
|
||||
{
|
||||
typedef typename boost::property_traits<PointPMap>::value_type Point;
|
||||
typedef typename Kernel_traits<Point>::Kernel Kernel;
|
||||
return write_xyz_points_and_normals(
|
||||
stream,
|
||||
first, beyond,
|
||||
point_pmap,
|
||||
normal_pmap,
|
||||
Kernel());
|
||||
CGAL_POINT_SET_PROCESSING_DEPRECATED_V1_API("write_xyz_points_and_normals()");
|
||||
CGAL::Iterator_range<ForwardIterator> points (first, beyond);
|
||||
return write_xyz_points
|
||||
(stream, points,
|
||||
CGAL::parameters::point_map (point_map).
|
||||
normal_map (normal_map));
|
||||
}
|
||||
/// @endcond
|
||||
|
||||
/// @cond SKIP_IN_MANUAL
|
||||
// This variant creates a default point property map = Identity_property_map.
|
||||
// deprecated API
|
||||
template <typename ForwardIterator,
|
||||
typename NormalPMap
|
||||
typename NormalMap
|
||||
>
|
||||
bool
|
||||
write_xyz_points_and_normals(
|
||||
std::ostream& stream, ///< output stream.
|
||||
ForwardIterator first, ///< first input point.
|
||||
ForwardIterator beyond, ///< past-the-end input point.
|
||||
NormalPMap normal_pmap) ///< property map: value_type of ForwardIterator -> Vector_3.
|
||||
NormalMap normal_map) ///< property map: value_type of ForwardIterator -> Vector_3.
|
||||
{
|
||||
return write_xyz_points_and_normals(
|
||||
stream,
|
||||
first, beyond,
|
||||
make_identity_property_map(
|
||||
typename std::iterator_traits<ForwardIterator>::value_type()),
|
||||
normal_pmap);
|
||||
CGAL_POINT_SET_PROCESSING_DEPRECATED_V1_API("write_xyz_points_and_normals()");
|
||||
CGAL::Iterator_range<ForwardIterator> points (first, beyond);
|
||||
return write_xyz_points
|
||||
(stream, points,
|
||||
CGAL::parameters::normal_map(normal_map));
|
||||
}
|
||||
/// @endcond
|
||||
|
||||
|
||||
//===================================================================================
|
||||
/// \ingroup PkgPointSetProcessingIO
|
||||
/// Saves the [first, beyond) range of points (positions only) to a .xyz ASCII stream.
|
||||
/// The function writes for each point a line with the x y z position.
|
||||
///
|
||||
/// @tparam ForwardIterator iterator over input points.
|
||||
/// @tparam PointPMap is a model of `ReadablePropertyMap` with value type `Point_3<Kernel>`.
|
||||
/// It can be omitted if the value type of `ForwardIterator value_type is convertible to `Point_3<Kernel>`.
|
||||
/// @tparam Kernel Geometric traits class.
|
||||
/// It can be omitted and deduced automatically from the value type of `PointPMap`.
|
||||
///
|
||||
/// @return true on success.
|
||||
|
||||
// This variant requires all parameters.
|
||||
// deprecated API
|
||||
template <typename ForwardIterator,
|
||||
typename PointPMap,
|
||||
typename PointMap,
|
||||
typename Kernel
|
||||
>
|
||||
bool
|
||||
write_xyz_points(
|
||||
std::ostream& stream, ///< output stream.
|
||||
ForwardIterator first, ///< iterator over the first input point.
|
||||
ForwardIterator beyond, ///< past-the-end iterator over the input points.
|
||||
PointPMap point_pmap, ///< property map: value_type of ForwardIterator -> Point_3.
|
||||
const Kernel& /*kernel*/) ///< geometric traits.
|
||||
ForwardIterator first, ///< first input point.
|
||||
ForwardIterator beyond, ///< past-the-end input point.
|
||||
PointMap point_map, ///< property map: value_type of OutputIterator -> Point_3.
|
||||
const Kernel& kernel)
|
||||
{
|
||||
CGAL_point_set_processing_precondition(first != beyond);
|
||||
|
||||
if(!stream)
|
||||
{
|
||||
std::cerr << "Error: cannot open file" << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
// Write positions
|
||||
for(ForwardIterator it = first; it != beyond; it++)
|
||||
stream << get(point_pmap, *it) << std::endl;
|
||||
|
||||
return ! stream.fail();
|
||||
CGAL_POINT_SET_PROCESSING_DEPRECATED_V1_API("write_xyz_points()");
|
||||
CGAL::Iterator_range<ForwardIterator> points (first, beyond);
|
||||
return write_xyz_points
|
||||
(stream, points,
|
||||
CGAL::parameters::point_map(point_map).
|
||||
geom_traits (kernel));
|
||||
}
|
||||
|
||||
/// @cond SKIP_IN_MANUAL
|
||||
// This variant deduces the kernel from the point property map.
|
||||
// deprecated API
|
||||
template <typename ForwardIterator,
|
||||
typename PointPMap
|
||||
typename PointMap
|
||||
>
|
||||
bool
|
||||
write_xyz_points(
|
||||
std::ostream& stream, ///< output stream.
|
||||
ForwardIterator first, ///< first input point.
|
||||
ForwardIterator beyond, ///< past-the-end input point.
|
||||
PointPMap point_pmap) ///< property map: value_type of OutputIterator -> Point_3.
|
||||
PointMap point_map) ///< property map: value_type of OutputIterator -> Point_3.
|
||||
{
|
||||
typedef typename boost::property_traits<PointPMap>::value_type Point;
|
||||
typedef typename Kernel_traits<Point>::Kernel Kernel;
|
||||
return write_xyz_points(
|
||||
stream,
|
||||
first, beyond,
|
||||
point_pmap,
|
||||
Kernel());
|
||||
CGAL_POINT_SET_PROCESSING_DEPRECATED_V1_API("write_xyz_points()");
|
||||
CGAL::Iterator_range<ForwardIterator> points (first, beyond);
|
||||
return write_xyz_points
|
||||
(stream, points,
|
||||
CGAL::parameters::point_map(point_map));
|
||||
}
|
||||
/// @endcond
|
||||
|
||||
/// @cond SKIP_IN_MANUAL
|
||||
// This variant creates a default point property map = Identity_property_map.
|
||||
// deprecated API
|
||||
template <typename ForwardIterator
|
||||
>
|
||||
bool
|
||||
|
|
@ -204,14 +225,12 @@ write_xyz_points(
|
|||
ForwardIterator first, ///< first input point.
|
||||
ForwardIterator beyond) ///< past-the-end input point.
|
||||
{
|
||||
return write_xyz_points(
|
||||
stream,
|
||||
first, beyond,
|
||||
make_identity_property_map(
|
||||
typename std::iterator_traits<ForwardIterator>::value_type())
|
||||
);
|
||||
CGAL_POINT_SET_PROCESSING_DEPRECATED_V1_API("write_xyz_points()");
|
||||
CGAL::Iterator_range<ForwardIterator> points (first, beyond);
|
||||
return write_xyz_points
|
||||
(stream, points);
|
||||
}
|
||||
/// @endcond
|
||||
/// \endcond
|
||||
|
||||
|
||||
} //namespace CGAL
|
||||
|
|
|
|||
|
|
@ -51,9 +51,10 @@ void test_bilateral_smoothing(std::deque<PointVectorPair>& points,// input point
|
|||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
CGAL::bilateral_smooth_point_set <Concurrency_tag>(
|
||||
points, nb_neighbors, sharpness_sigma,
|
||||
points, nb_neighbors,
|
||||
CGAL::parameters::point_map(CGAL::First_of_pair_property_map<PointVectorPair>()).
|
||||
normal_map(CGAL::Second_of_pair_property_map<PointVectorPair>()));
|
||||
normal_map(CGAL::Second_of_pair_property_map<PointVectorPair>()).
|
||||
sharpness_angle (sharpness_sigma));
|
||||
}
|
||||
|
||||
std::size_t memory = CGAL::Memory_sizer().virtual_size();
|
||||
|
|
@ -112,10 +113,10 @@ int main(int argc, char * argv[])
|
|||
// If XYZ file format:
|
||||
std::ifstream stream(input_filename.c_str());
|
||||
if(stream &&
|
||||
CGAL::read_xyz_points_and_normals(stream,
|
||||
std::back_inserter(points),
|
||||
CGAL::First_of_pair_property_map<PointVectorPair>(),
|
||||
CGAL::Second_of_pair_property_map<PointVectorPair>()))
|
||||
CGAL::read_xyz_points(stream,
|
||||
std::back_inserter(points),
|
||||
CGAL::parameters::point_map(CGAL::First_of_pair_property_map<PointVectorPair>()).
|
||||
normal_map(CGAL::Second_of_pair_property_map<PointVectorPair>())))
|
||||
{
|
||||
std::cerr << "ok (" << points.size() << " points)" << std::endl;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -128,11 +128,11 @@ int main(int argc, char * argv[])
|
|||
// If XYZ file format:
|
||||
std::ifstream stream(input_filename.c_str());
|
||||
if(stream &&
|
||||
CGAL::read_xyz_points_and_normals
|
||||
CGAL::read_xyz_points
|
||||
(stream,
|
||||
std::back_inserter(points),
|
||||
CGAL::First_of_pair_property_map<PointVectorPair>(),
|
||||
CGAL::Second_of_pair_property_map<PointVectorPair>()))
|
||||
CGAL::parameters::point_map(CGAL::First_of_pair_property_map<PointVectorPair>()).
|
||||
normal_map(CGAL::Second_of_pair_property_map<PointVectorPair>())))
|
||||
{
|
||||
std::cerr << "ok (" << points.size() << " points)" << std::endl;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -319,10 +319,11 @@ int main(int argc, char * argv[])
|
|||
{
|
||||
std::ifstream stream(input_filename.c_str());
|
||||
success = stream &&
|
||||
CGAL::read_off_points_and_normals(stream,
|
||||
std::back_inserter(points),
|
||||
CGAL::make_normal_of_point_with_normal_map(PointList::value_type())
|
||||
);
|
||||
CGAL::read_off_points(stream,
|
||||
std::back_inserter(points),
|
||||
CGAL::parameters::normal_map
|
||||
(CGAL::make_normal_of_point_with_normal_map(PointList::value_type()))
|
||||
);
|
||||
}
|
||||
// If XYZ file format
|
||||
else if (extension == ".xyz" || extension == ".XYZ" ||
|
||||
|
|
@ -330,10 +331,11 @@ int main(int argc, char * argv[])
|
|||
{
|
||||
std::ifstream stream(input_filename.c_str());
|
||||
success = stream &&
|
||||
CGAL::read_xyz_points_and_normals(stream,
|
||||
std::back_inserter(points),
|
||||
CGAL::make_normal_of_point_with_normal_map(PointList::value_type())
|
||||
);
|
||||
CGAL::read_xyz_points(stream,
|
||||
std::back_inserter(points),
|
||||
CGAL::parameters::normal_map
|
||||
(CGAL::make_normal_of_point_with_normal_map(PointList::value_type()))
|
||||
);
|
||||
}
|
||||
if (success)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -23,10 +23,10 @@ bool read(std::string s)
|
|||
{
|
||||
std::ifstream fs(s.c_str());
|
||||
std::vector<PointVectorPair> pv_pairs;
|
||||
return CGAL::read_xyz_points_and_normals(fs,
|
||||
back_inserter(pv_pairs),
|
||||
CGAL::First_of_pair_property_map<PointVectorPair>(),
|
||||
CGAL::Second_of_pair_property_map<PointVectorPair>());
|
||||
return CGAL::read_xyz_points(fs,
|
||||
back_inserter(pv_pairs),
|
||||
CGAL::parameters::point_map(CGAL::First_of_pair_property_map<PointVectorPair>()).
|
||||
normal_map(CGAL::Second_of_pair_property_map<PointVectorPair>()));
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -36,10 +36,10 @@ bool read(std::string s,
|
|||
{
|
||||
std::ifstream fs(s.c_str());
|
||||
|
||||
return CGAL::read_xyz_points_and_normals(fs,
|
||||
back_inserter(pv_pairs),
|
||||
CGAL::First_of_pair_property_map<PointVectorPair>(),
|
||||
CGAL::Second_of_pair_property_map<PointVectorPair>());
|
||||
return CGAL::read_xyz_points(fs,
|
||||
back_inserter(pv_pairs),
|
||||
CGAL::parameters::point_map(CGAL::First_of_pair_property_map<PointVectorPair>()).
|
||||
normal_map(CGAL::Second_of_pair_property_map<PointVectorPair>()));
|
||||
}
|
||||
|
||||
bool read_off(std::string s,
|
||||
|
|
@ -47,10 +47,10 @@ bool read_off(std::string s,
|
|||
{
|
||||
std::ifstream fs(s.c_str());
|
||||
|
||||
return CGAL::read_off_points_and_normals(fs,
|
||||
back_inserter(pv_pairs),
|
||||
CGAL::First_of_pair_property_map<PointVectorPair>(),
|
||||
CGAL::Second_of_pair_property_map<PointVectorPair>());
|
||||
return CGAL::read_off_points(fs,
|
||||
back_inserter(pv_pairs),
|
||||
CGAL::parameters::point_map(CGAL::First_of_pair_property_map<PointVectorPair>()).
|
||||
normal_map(CGAL::Second_of_pair_property_map<PointVectorPair>()));
|
||||
}
|
||||
|
||||
#ifdef CGAL_CXX11
|
||||
|
|
@ -59,10 +59,10 @@ bool read_ply (std::string s,
|
|||
{
|
||||
std::ifstream fs(s.c_str());
|
||||
|
||||
return CGAL::read_ply_points_and_normals (fs,
|
||||
back_inserter(pv_pairs),
|
||||
CGAL::First_of_pair_property_map<PointVectorPair>(),
|
||||
CGAL::Second_of_pair_property_map<PointVectorPair>());
|
||||
return CGAL::read_ply_points (fs,
|
||||
back_inserter(pv_pairs),
|
||||
CGAL::parameters::point_map(CGAL::First_of_pair_property_map<PointVectorPair>()).
|
||||
normal_map(CGAL::Second_of_pair_property_map<PointVectorPair>()));
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -78,18 +78,21 @@ bool test_no_deduction_points_and_normals_xyz(const char* file_name)
|
|||
// read with custom output iterator type
|
||||
dummy_counter::counter = 0;
|
||||
std::ifstream input(file_name);
|
||||
CGAL::read_xyz_points_and_normals<dummy_counter>(
|
||||
input, back_inserter(indices), points, normals, Kernel());
|
||||
CGAL::read_xyz_points<dummy_counter>(
|
||||
input, back_inserter(indices),
|
||||
CGAL::parameters::point_map (points).
|
||||
normal_map (normals).
|
||||
geom_traits (Kernel()));
|
||||
|
||||
// read with ordinary pmaps
|
||||
input.clear();
|
||||
input.close();
|
||||
input.open(file_name);
|
||||
CGAL::read_xyz_points_and_normals(
|
||||
input, back_inserter(pv_pairs),
|
||||
CGAL::First_of_pair_property_map<PointVectorPair>(),
|
||||
CGAL::Second_of_pair_property_map<PointVectorPair>(),
|
||||
Kernel());
|
||||
CGAL::read_xyz_points(
|
||||
input, back_inserter(pv_pairs),
|
||||
CGAL::parameters::point_map(CGAL::First_of_pair_property_map<PointVectorPair>()).
|
||||
normal_map(CGAL::Second_of_pair_property_map<PointVectorPair>()).
|
||||
geom_traits(Kernel()));
|
||||
|
||||
return check_points_and_vectors(points, normals, pv_pairs, indices);
|
||||
}
|
||||
|
|
@ -105,18 +108,21 @@ bool test_no_deduction_points_and_normals_off(const char* file_name)
|
|||
// read with custom output iterator type
|
||||
dummy_counter::counter = 0;
|
||||
std::ifstream input(file_name);
|
||||
CGAL::read_off_points_and_normals<dummy_counter>(
|
||||
input, back_inserter(indices), points, normals, Kernel());
|
||||
CGAL::read_off_points<dummy_counter>(
|
||||
input, back_inserter(indices),
|
||||
CGAL::parameters::point_map(points).
|
||||
normal_map(normals).
|
||||
geom_traits(Kernel()));
|
||||
|
||||
// read with ordinary pmaps
|
||||
input.clear();
|
||||
input.close();
|
||||
input.open(file_name);
|
||||
CGAL::read_off_points_and_normals(
|
||||
CGAL::read_off_points(
|
||||
input, back_inserter(pv_pairs),
|
||||
CGAL::First_of_pair_property_map<PointVectorPair>(),
|
||||
CGAL::Second_of_pair_property_map<PointVectorPair>(),
|
||||
Kernel());
|
||||
CGAL::parameters::point_map(CGAL::First_of_pair_property_map<PointVectorPair>()).
|
||||
normal_map(CGAL::Second_of_pair_property_map<PointVectorPair>()).
|
||||
geom_traits(Kernel()));
|
||||
|
||||
return check_points_and_vectors(points, normals, pv_pairs, indices);
|
||||
}
|
||||
|
|
@ -132,7 +138,8 @@ bool test_no_deduction_points_xyz(const char* file_name)
|
|||
dummy_counter::counter = 0;
|
||||
std::ifstream input(file_name);
|
||||
CGAL::read_xyz_points<dummy_counter>(
|
||||
input, back_inserter(indices), points_1, Kernel());
|
||||
input, back_inserter(indices),
|
||||
CGAL::parameters::point_map(points_1).geom_traits(Kernel()));
|
||||
|
||||
// read with ordinary pmaps
|
||||
input.clear();
|
||||
|
|
@ -140,8 +147,8 @@ bool test_no_deduction_points_xyz(const char* file_name)
|
|||
input.open(file_name);
|
||||
CGAL::read_xyz_points(
|
||||
input, back_inserter(points_2),
|
||||
CGAL::Identity_property_map<Point_3>(),
|
||||
Kernel());
|
||||
CGAL::parameters::point_map(CGAL::Identity_property_map<Point_3>()).
|
||||
geom_traits(Kernel()));
|
||||
|
||||
return check_points(points_1, points_2, indices);
|
||||
}
|
||||
|
|
@ -157,7 +164,9 @@ bool test_no_deduction_points_off(const char* file_name)
|
|||
dummy_counter::counter = 0;
|
||||
std::ifstream input(file_name);
|
||||
CGAL::read_off_points<dummy_counter>(
|
||||
input, back_inserter(indices), points_1, Kernel());
|
||||
input, back_inserter(indices),
|
||||
CGAL::parameters::point_map(points_1).
|
||||
geom_traits(Kernel()));
|
||||
|
||||
// read with ordinary pmaps
|
||||
input.clear();
|
||||
|
|
@ -165,8 +174,8 @@ bool test_no_deduction_points_off(const char* file_name)
|
|||
input.open(file_name);
|
||||
CGAL::read_off_points(
|
||||
input, back_inserter(points_2),
|
||||
CGAL::Identity_property_map<Point_3>(),
|
||||
Kernel());
|
||||
CGAL::parameters::point_map(CGAL::Identity_property_map<Point_3>()).
|
||||
geom_traits(Kernel()));
|
||||
|
||||
return check_points(points_1, points_2, indices);
|
||||
}
|
||||
|
|
@ -188,7 +197,7 @@ void compile_test() {
|
|||
CGAL::read_xyz_points(
|
||||
input,
|
||||
std::front_inserter(points),
|
||||
CGAL::Identity_property_map<Point_3>());
|
||||
CGAL::parameters::point_map(CGAL::Identity_property_map<Point_3>()));
|
||||
input.clear();
|
||||
input.close();
|
||||
|
||||
|
|
@ -196,8 +205,8 @@ void compile_test() {
|
|||
CGAL::read_xyz_points(
|
||||
input,
|
||||
std::front_inserter(points),
|
||||
CGAL::Identity_property_map<Point_3>(),
|
||||
Kernel());
|
||||
CGAL::parameters::point_map(CGAL::Identity_property_map<Point_3>()).
|
||||
geom_traits(Kernel()));
|
||||
input.clear();
|
||||
input.close();
|
||||
|
||||
|
|
@ -220,7 +229,7 @@ void compile_test() {
|
|||
CGAL::read_off_points(
|
||||
input,
|
||||
std::front_inserter(points),
|
||||
CGAL::Identity_property_map<Point_3>());
|
||||
CGAL::parameters::point_map(CGAL::Identity_property_map<Point_3>()));
|
||||
input.clear();
|
||||
input.close();
|
||||
|
||||
|
|
@ -228,8 +237,8 @@ void compile_test() {
|
|||
CGAL::read_off_points(
|
||||
input,
|
||||
std::front_inserter(points),
|
||||
CGAL::Identity_property_map<Point_3>(),
|
||||
Kernel());
|
||||
CGAL::parameters::point_map(CGAL::Identity_property_map<Point_3>()).
|
||||
geom_traits(Kernel()));
|
||||
input.clear();
|
||||
input.close();
|
||||
|
||||
|
|
@ -242,72 +251,72 @@ void compile_test() {
|
|||
input.close();
|
||||
//-----------------------------------------------------------------------
|
||||
input.open("data/read_test/simple.xyz");
|
||||
CGAL::read_xyz_points_and_normals(
|
||||
CGAL::read_xyz_points(
|
||||
input,
|
||||
std::front_inserter(points),
|
||||
boost::dummy_property_map());
|
||||
CGAL::parameters::normal_map(boost::dummy_property_map()));
|
||||
input.clear();
|
||||
input.close();
|
||||
|
||||
input.open("data/read_test/simple.xyz");
|
||||
CGAL::read_xyz_points_and_normals(
|
||||
CGAL::read_xyz_points(
|
||||
input,
|
||||
std::front_inserter(pv_pairs),
|
||||
CGAL::First_of_pair_property_map<PointVectorPair>(),
|
||||
CGAL::Second_of_pair_property_map<PointVectorPair>());
|
||||
CGAL::parameters::point_map(CGAL::First_of_pair_property_map<PointVectorPair>()).
|
||||
normal_map(CGAL::Second_of_pair_property_map<PointVectorPair>()));
|
||||
input.clear();
|
||||
input.close();
|
||||
|
||||
input.open("data/read_test/simple.xyz");
|
||||
CGAL::read_xyz_points_and_normals(
|
||||
CGAL::read_xyz_points(
|
||||
input,
|
||||
std::front_inserter(pv_pairs),
|
||||
CGAL::First_of_pair_property_map<PointVectorPair>(),
|
||||
CGAL::Second_of_pair_property_map<PointVectorPair>(),
|
||||
Kernel());
|
||||
CGAL::parameters::point_map(CGAL::First_of_pair_property_map<PointVectorPair>()).
|
||||
normal_map(CGAL::Second_of_pair_property_map<PointVectorPair>()).
|
||||
geom_traits(Kernel()));
|
||||
input.clear();
|
||||
input.close();
|
||||
|
||||
input.open("data/read_test/simple.xyz");
|
||||
CGAL::read_xyz_points_and_normals<Point_3>(
|
||||
CGAL::read_xyz_points<Point_3>(
|
||||
input,
|
||||
std::front_inserter(points),
|
||||
boost::dummy_property_map());
|
||||
CGAL::parameters::normal_map(boost::dummy_property_map()));
|
||||
input.clear();
|
||||
input.close();
|
||||
//-----------------------------------------------------------------------
|
||||
input.open("data/read_test/simple.off");
|
||||
CGAL::read_off_points_and_normals(
|
||||
CGAL::read_off_points(
|
||||
input,
|
||||
std::front_inserter(points),
|
||||
boost::dummy_property_map());
|
||||
CGAL::parameters::normal_map(boost::dummy_property_map()));
|
||||
input.clear();
|
||||
input.close();
|
||||
|
||||
input.open("data/read_test/simple.off");
|
||||
CGAL::read_off_points_and_normals(
|
||||
CGAL::read_off_points(
|
||||
input,
|
||||
std::front_inserter(pv_pairs),
|
||||
CGAL::First_of_pair_property_map<PointVectorPair>(),
|
||||
CGAL::Second_of_pair_property_map<PointVectorPair>());
|
||||
CGAL::parameters::point_map(CGAL::First_of_pair_property_map<PointVectorPair>()).
|
||||
normal_map(CGAL::Second_of_pair_property_map<PointVectorPair>()));
|
||||
input.clear();
|
||||
input.close();
|
||||
|
||||
input.open("data/read_test/simple.off");
|
||||
CGAL::read_off_points_and_normals(
|
||||
CGAL::read_off_points(
|
||||
input,
|
||||
std::front_inserter(pv_pairs),
|
||||
CGAL::First_of_pair_property_map<PointVectorPair>(),
|
||||
CGAL::Second_of_pair_property_map<PointVectorPair>(),
|
||||
Kernel());
|
||||
CGAL::parameters::point_map(CGAL::First_of_pair_property_map<PointVectorPair>()).
|
||||
normal_map(CGAL::Second_of_pair_property_map<PointVectorPair>()).
|
||||
geom_traits(Kernel()));
|
||||
input.clear();
|
||||
input.close();
|
||||
|
||||
input.open("data/read_test/simple.off");
|
||||
CGAL::read_off_points_and_normals<Point_3>(
|
||||
CGAL::read_off_points<Point_3>(
|
||||
input,
|
||||
std::front_inserter(points),
|
||||
boost::dummy_property_map());
|
||||
CGAL::parameters::normal_map(boost::dummy_property_map()));
|
||||
input.clear();
|
||||
input.close();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ std::cout << "=== test_fandisk ===\n";
|
|||
if (!stream ||
|
||||
!CGAL::read_off_points(stream,
|
||||
std::back_inserter(points),
|
||||
pmap))
|
||||
CGAL::parameters::point_map(pmap)))
|
||||
{
|
||||
std::cerr << "Error: cannot read file data/fandisk.off" << std::endl;
|
||||
return false;
|
||||
|
|
|
|||
Loading…
Reference in New Issue