20 #include <CGAL/Point_set_3/IO.h>
21 #include <CGAL/IO/read_ply_points.h>
39 std::string line, word;
43 std::getline(in, line);
44 std::istringstream line_ss(line);
48 if(word ==
"property")
57 else if(word ==
"red")
63 else if(word ==
"format")
67 if(word ==
"binary_little_endian" || word ==
"binary_big_endian")
73 while(word !=
"end_header");
84 const unsigned char &g,
85 const unsigned char &b)
111 const std::string &filename,
117 bool success =
false;
120 std::ifstream in(filename);
123 throw std::invalid_argument(
"read_mesh() error: can not open file " +
131 success = CGAL::read_xyz_point_set(in, g);
133 if(g.has_normal_map())
139 success = CGAL::read_off_point_set(in, g);
141 if(g.has_normal_map())
156 in.open(filename, std::ios::binary);
160 throw std::invalid_argument(
"read_mesh() error: can not open file " +
161 filename +
" in binary mode.");
166 using VertexNormalMap =
169 using VertexColorMap =
172 VertexNormalMap v_nm;
187 if(has_normal && has_color)
189 success = CGAL::read_ply_points_with_properties(
191 g.index_back_inserter(),
192 CGAL::make_ply_point_reader(g.point_push_map()),
193 CGAL::make_ply_normal_reader(g.push_property_map(v_nm)),
194 std::make_tuple(g.push_property_map(v_cm),
196 CGAL::PLY_property< unsigned char >(
"red"),
197 CGAL::PLY_property< unsigned char >(
"green"),
198 CGAL::PLY_property< unsigned char >(
"blue")));
203 success = CGAL::read_ply_points_with_properties(
205 g.index_back_inserter(),
206 CGAL::make_ply_point_reader(g.point_push_map()),
207 CGAL::make_ply_normal_reader(g.push_property_map(v_nm)));
211 success = CGAL::read_ply_points_with_properties(
213 g.index_back_inserter(),
214 CGAL::make_ply_point_reader(g.point_push_map()),
215 std::make_tuple(g.push_property_map(v_cm),
217 CGAL::PLY_property< unsigned char >(
"red"),
218 CGAL::PLY_property< unsigned char >(
"green"),
219 CGAL::PLY_property< unsigned char >(
"blue")));
224 success = CGAL::read_ply_points_with_properties(
226 g.index_back_inserter(),
227 CGAL::make_ply_point_reader(g.point_push_map()));
233 throw std::invalid_argument(
"read_mesh() error: can not read file " +