#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/property_map.h>
#include <CGAL/IO/read_ply_points.h>
#include <utility>
#include <vector>
#include <fstream>
typedef std::pair<Point, Vector> Pwn;
class My_ply_interpreter
{
std::vector<Pwn>& points;
std::vector<Color>& colors;
public:
My_ply_interpreter (std::vector<Pwn>& points,
std::vector<Color>& colors)
: points (points), colors (colors)
{ }
{
}
{
FT x = (FT)0., y = (FT)0., z = (FT)0.,
nx = (FT)0., ny = (FT)0., nz = (FT)0.;
Color c = {{ 0, 0, 0 }};
reader.
assign (c[1],
"green");
points.push_back (std::make_pair (Point (x, y, z), Vector (nx, ny, nz)));
colors.push_back (c);
}
};
int main(int argc, char*argv[])
{
const char* fname = (argc>1) ? argv[1] : "data/colors.ply";
std::vector<Pwn> points;
std::vector<Color> colors;
My_ply_interpreter interpreter(points, colors);
std::ifstream in(fname);
if (!in ||
{
std::cerr << "Error: cannot read file " << fname << std::endl;
return EXIT_FAILURE;
}
for (std::size_t i = 0; i < points.size (); ++ i)
if (colors[i][0] == 255 && colors[i][1] == 0 && colors[i][2] == 0)
std::cerr << "Point " << points[i].first << " is red." << std::endl;
else if (colors[i][0] == 0 && colors[i][1] == 255 && colors[i][2] == 0)
std::cerr << "Point " << points[i].first << " is green." << std::endl;
else if (colors[i][0] == 0 && colors[i][1] == 0 && colors[i][2] == 255)
std::cerr << "Point " << points[i].first << " is blue." << std::endl;
return EXIT_SUCCESS;
}