Example #1
0
void raw_print_tiles_impl(std::ostream& out, Point_iter points_begin, Point_iter points_end, double z_scale, bool color)
{
    static log4cplus::Logger logger = log4cplus::Logger::getInstance("raw_print_tiles_impl");

    // out << std::setprecision(12);

    typedef typename iterator_traits<Point_iter>::value_type Point_type;
    typedef boost::unordered_map<Point_type, size_t> Vertex_map;

    Vertex_map vertices;
    size_t next_idx = 0;
    size_t num_points = 0;
    stringstream ss;
    // ss << std::setprecision(24);
    for (Point_iter it = points_begin; it != points_end; ++it)
    {
        const Point_type& t = *it;
        if (vertices.find(t) == vertices.end())
        {
            // // debug
            // if (abs(it->x() - 5.2767) < 0.0001) {
            //   LOG4CPLUS_WARN(logger, "looking for this? " << it->x() <<
            //                  " " << it->y() << " " << (it->z()+0.5) * z_scale <<
            //                  " " << it->point().id());
            // }
            // // /debug

            Color c = get_color(t);
            vertices[t] = next_idx++;
            ss << t.x() << " " << t.y() << " " << (t.z()+0.5) * z_scale;
            if (color)
                ss << " " << c.r() << " " << c.g() << " " << c.b();
            ss << endl;
        }
        ++num_points;
    }
    size_t num_verts = vertices.size();
    num_points /= 3;

    out << num_verts << " " << num_points << endl;
    out << ss.str();

    size_t n = 0;
    for (Point_iter it = points_begin; it != points_end; ++it)
    {
        out << vertices[*it] << " ";
        if ((++n) % 3 == 0)
            out << endl;
    }
}