From b8a74bf30f11f49e8192b87daf7d08b67a45e32e Mon Sep 17 00:00:00 2001 From: Simon Giraudot Date: Thu, 14 Jan 2016 10:55:27 +0100 Subject: [PATCH] Add test to check if interpreter is applicable to current ply file --- .../include/CGAL/IO/read_ply_points.h | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/Point_set_processing_3/include/CGAL/IO/read_ply_points.h b/Point_set_processing_3/include/CGAL/IO/read_ply_points.h index a51237b52c1..cdfd0f5e81d 100644 --- a/Point_set_processing_3/include/CGAL/IO/read_ply_points.h +++ b/Point_set_processing_3/include/CGAL/IO/read_ply_points.h @@ -214,6 +214,20 @@ namespace internal { m_point_pmap (point_pmap), m_normal_pmap (normal_pmap) { } + + bool is_applicable (const std::vector& readers) + { + bool x_found = false, y_found = false, z_found = false; + for (std::size_t i = 0; i < readers.size (); ++ i) + if (readers[i]->name () == "x") + x_found = true; + else if (readers[i]->name () == "y") + y_found = true; + else if (readers[i]->name () == "z") + z_found = true; + + return x_found && y_found && z_found; + } void operator() (const std::vector& readers) { @@ -450,7 +464,9 @@ bool read_ply_points_and_normals(std::istream& stream, ///< input stream. internal::Ply_builder_point_3 builder (output, point_pmap, normal_pmap); - + + if (!(builder.is_applicable (readers))) + return false; return internal::read_ply_content (stream, builder, nb_points, readers, kernel); }